org.springframework.dao.InvalidDataAccessApiUsageException: No aliases found in result tuple! Make sure your query defines aliases!; nested exception is java.lang.IllegalStateException: No aliases found in result tuple! Make sure your query defines aliases!

Stack Overflow | Federico Russo | 8 months ago
tip
Do you know that we can give you better hits? Get more relevant results from Samebug’s stack trace search.
  1. 0

    Exception Spring Data Hopper-SR3: No aliases found in result tuple. Make sure your query defines aliases

    Stack Overflow | 8 months ago | Federico Russo
    org.springframework.dao.InvalidDataAccessApiUsageException: No aliases found in result tuple! Make sure your query defines aliases!; nested exception is java.lang.IllegalStateException: No aliases found in result tuple! Make sure your query defines aliases!
  2. 0

    After migrating Spring Data application from Gosling-SR4 to Hopper-SR1 release, all custom queries that extends JpaRepository throws the following message: {code:java} Caused by: java.lang.IllegalStateException: No aliases found in result tuple! Make sure your query defines aliases! at org.springframework.data.jpa.repository.query.AbstractJpaQuery$TupleConverter.convert(AbstractJpaQuery.java:246) [spring-data-jpa-1.10.1.RELEASE.jar:] at org.springframework.data.repository.query.ResultProcessor$ChainingConverter.convert(ResultProcessor.java:185) [spring-data-commons-1.12.1.RELEASE.jar:] at org.springframework.data.repository.query.ResultProcessor$ChainingConverter$1.convert(ResultProcessor.java:173) [spring-data-commons-1.12.1.RELEASE.jar:] at org.springframework.data.repository.query.ResultProcessor$ChainingConverter.convert(ResultProcessor.java:185) [spring-data-commons-1.12.1.RELEASE.jar:] at org.springframework.data.repository.query.ResultProcessor.processResult(ResultProcessor.java:142) [spring-data-commons-1.12.1.RELEASE.jar:] at org.springframework.data.jpa.repository.query.AbstractJpaQuery.doExecute(AbstractJpaQuery.java:107) [spring-data-jpa-1.10.1.RELEASE.jar:] at org.springframework.data.jpa.repository.query.AbstractJpaQuery.execute(AbstractJpaQuery.java:92) [spring-data-jpa-1.10.1.RELEASE.jar:] at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:482) [spring-data-commons-1.12.1.RELEASE.jar:] at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:460) [spring-data-commons-1.12.1.RELEASE.jar:] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) [spring-aop-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99) [spring-tx-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281) [spring-tx-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) [spring-tx-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) [spring-aop-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136) [spring-tx-4.2.5.RELEASE.jar:4.2.5.RELEASE] ... 113 more {code} {code:java} public interface UserProfileAccessGroupRepository extends JpaRepository<UserProfileAccessGroup, UserProfileAccessGroupPK> { @Modifying @Query("DELETE FROM UserProfileAccessGroup upag WHERE upag.id.accessGroup = ?1") public void deleteByAccessGroup(AccessGroup accessGroup); @Modifying @Query("DELETE FROM UserProfileAccessGroup upag WHERE upag.id.userProfile = ?1") public void deleteByUserProfile(UserProfile userProfile); @Query("SELECT upag.id.accessGroup FROM UserProfileAccessGroup upag WHERE upag.id.userProfile = ?1") public List<AccessGroup> findAccessGroupByUserProfile(UserProfile userProfile); @Query("SELECT upag.id.accessGroup FROM UserProfileAccessGroup upag WHERE upag.id.userProfile = ?1 AND upag.id.accessGroup.functionality = false") public List<AccessGroup> findGroupByUserProfile(UserProfile userProfile); public List<UserProfileAccessGroup> findByExpirationDateBefore(Date date); } {code} {code:java} @Entity public class UserProfileAccessGroup implements Serializable { private static final long serialVersionUID = 1L; @EmbeddedId private UserProfileAccessGroupPK id; private Date expirationDate; @ManyToOne @JoinColumn(name = "authorizedBy") private UserProfile authorizedBy; public UserProfileAccessGroupPK getId() { if (id == null) { id = new UserProfileAccessGroupPK(); } return id; } public void setId(UserProfileAccessGroupPK id) { this.id = id; } public Date getExpirationDate() { return expirationDate; } public void setExpirationDate(Date expirationDate) { this.expirationDate = expirationDate; } public UserProfile getAuthorizedBy() { return authorizedBy; } public void setAuthorizedBy(UserProfile authorizedBy) { this.authorizedBy = authorizedBy; } @Embeddable public static class UserProfileAccessGroupPK implements Serializable { private static final long serialVersionUID = 1L; @ManyToOne @JoinColumn(name = "accessGroupId") private AccessGroup accessGroup; @ManyToOne @JoinColumn(name = "userProfileId") private UserProfile userProfile; public UserProfileAccessGroupPK() { } public UserProfileAccessGroupPK(AccessGroup accessGroup, UserProfile userProfile) { this.accessGroup = accessGroup; this.userProfile = userProfile; } public AccessGroup getAccessGroup() { return accessGroup; } public void setAccessGroup(AccessGroup accessGroup) { this.accessGroup = accessGroup; } public UserProfile getUserProfile() { return userProfile; } public void setUserProfile(UserProfile userProfile) { this.userProfile = userProfile; } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((accessGroup == null) ? 0 : accessGroup.hashCode()); result = prime * result + ((userProfile == null) ? 0 : userProfile.hashCode()); return result; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; UserProfileAccessGroupPK other = (UserProfileAccessGroupPK) obj; if (accessGroup == null) { if (other.accessGroup != null) return false; } else if (!accessGroup.equals(other.accessGroup)) return false; if (userProfile == null) { if (other.userProfile != null) return false; } else if (!userProfile.equals(other.userProfile)) return false; return true; } } } {code}

    Spring JIRA | 1 year ago | ofbiz
    org.springframework.dao.InvalidDataAccessApiUsageException: No aliases found in result tuple! Make sure your query defines aliases!; nested exception is java.lang.IllegalStateException: No aliases found in result tuple! Make sure your query defines aliases!

Root Cause Analysis

  1. java.lang.IllegalStateException

    No aliases found in result tuple! Make sure your query defines aliases!

    at org.springframework.data.jpa.repository.query.AbstractJpaQuery$TupleConverter.convert()
  2. Spring Data JPA
    AbstractJpaQuery$TupleConverter.convert
    1. org.springframework.data.jpa.repository.query.AbstractJpaQuery$TupleConverter.convert(AbstractJpaQuery.java:258)
    1 frame
  3. Spring Data Core
    ResultProcessor.processResult
    1. org.springframework.data.repository.query.ResultProcessor$ChainingConverter.convert(ResultProcessor.java:196)
    2. org.springframework.data.repository.query.ResultProcessor$ChainingConverter$1.convert(ResultProcessor.java:184)
    3. org.springframework.data.repository.query.ResultProcessor$ChainingConverter.convert(ResultProcessor.java:196)
    4. org.springframework.data.repository.query.ResultProcessor.processResult(ResultProcessor.java:149)
    4 frames
  4. Spring Data JPA
    AbstractJpaQuery.execute
    1. org.springframework.data.jpa.repository.query.AbstractJpaQuery.doExecute(AbstractJpaQuery.java:119)
    2. org.springframework.data.jpa.repository.query.AbstractJpaQuery.execute(AbstractJpaQuery.java:104)
    2 frames
  5. Spring Data Core
    RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke
    1. org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:482)
    2. org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:460)
    2 frames
  6. Spring AOP
    ReflectiveMethodInvocation.proceed
    1. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    1 frame
  7. org.springframework.data
    DefaultMethodInvokingMethodInterceptor.invoke
    1. org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:61)
    1 frame
  8. Spring AOP
    ReflectiveMethodInvocation.proceed
    1. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    1 frame
  9. Spring Tx
    TransactionInterceptor.invoke
    1. org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
    2. org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
    3. org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
    3 frames
  10. Spring AOP
    ReflectiveMethodInvocation.proceed
    1. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    1 frame
  11. Spring Tx
    PersistenceExceptionTranslationInterceptor.invoke
    1. org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)
    1 frame
  12. Spring AOP
    ReflectiveMethodInvocation.proceed
    1. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    1 frame
  13. Spring Data JPA
    CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke
    1. org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:133)
    1 frame
  14. Spring AOP
    JdkDynamicAopProxy.invoke
    1. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    2. org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
    3. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    4. org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
    4 frames
  15. com.sun.proxy
    $Proxy223.findDescendentByStrategyAndAncestorId
    1. com.sun.proxy.$Proxy223.findDescendentByStrategyAndAncestorId(Unknown Source)
    1 frame
  16. it.imc.bo
    PlaceBOImpl$$FastClassBySpringCGLIB$$1a96fb97.invoke
    1. it.imc.bo.bom.PlaceBOImpl.findDescendents(PlaceBOImpl.java:2452)
    2. it.imc.bo.bom.PlaceBOImpl.findPlaces(PlaceBOImpl.java:2421)
    3. it.imc.bo.bom.PlaceBOImpl$$FastClassBySpringCGLIB$$1a96fb97.invoke(<generated>)
    3 frames
  17. Spring Core
    MethodProxy.invoke
    1. org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
    1 frame
  18. Spring AOP
    ReflectiveMethodInvocation.proceed
    1. org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:720)
    2. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
    2 frames
  19. Spring Tx
    TransactionInterceptor.invoke
    1. org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
    2. org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
    3. org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
    3 frames
  20. Spring AOP
    ReflectiveMethodInvocation.proceed
    1. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    1 frame
  21. spring-security-core
    MethodSecurityInterceptor.invoke
    1. org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:69)
    1 frame
  22. Spring AOP
    CglibAopProxy$DynamicAdvisedInterceptor.intercept
    1. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    2. org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:655)
    2 frames
  23. it.imc.bo
    PlaceBOTest.testFindDescendents
    1. it.imc.bo.bom.PlaceBOImpl$$EnhancerBySpringCGLIB$$7e317aea.findPlaces(<generated>)
    2. it.imc.bo.bom.PlaceBOTest.testFindDescendents(PlaceBOTest.java:179)
    2 frames
  24. Java RT
    Method.invoke
    1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    4. java.lang.reflect.Method.invoke(Method.java:498)
    4 frames
  25. JUnit
    RunBefores.evaluate
    1. org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    2. org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    3. org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    4. org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    5. org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    5 frames
  26. Spring TestContext
    RunBeforeTestMethodCallbacks.evaluate
    1. org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
    1 frame
  27. JUnit
    RunAfters.evaluate
    1. org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
    1 frame
  28. Spring TestContext
    RunAfterTestMethodCallbacks.evaluate
    1. org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
    1 frame
  29. JUnit
    RunRules.evaluate
    1. org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55)
    2. org.junit.rules.RunRules.evaluate(RunRules.java:20)
    2 frames
  30. Spring TestContext
    SpringRepeat.evaluate
    1. org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
    1 frame
  31. JUnit
    ParentRunner.runLeaf
    1. org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    1 frame
  32. Spring TestContext
    SpringJUnit4ClassRunner.runChild
    1. org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:252)
    2. org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94)
    2 frames
  33. JUnit
    ParentRunner$2.evaluate
    1. org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    2. org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    3. org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    4. org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    5. org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    5 frames
  34. Spring TestContext
    RunAfterTestClassCallbacks.evaluate
    1. org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
    2. org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
    2 frames
  35. JUnit
    ParentRunner.run
    1. org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    1 frame
  36. Spring TestContext
    SpringJUnit4ClassRunner.run
    1. org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)
    1 frame
  37. JUnit
    JUnitCore.run
    1. org.junit.runners.Suite.runChild(Suite.java:128)
    2. org.junit.runners.Suite.runChild(Suite.java:27)
    3. org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    4. org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    5. org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    6. org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    7. org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    8. org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    9. org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    9 frames
  38. IntelliJ junit4 module
    JUnit4IdeaTestRunner.startRunnerWithArgs
    1. com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:117)
    2. com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42)
    2 frames
  39. IDEA
    JUnitStarter.main
    1. com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:262)
    2. com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:84)
    2 frames
  40. Java RT
    Method.invoke
    1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    4. java.lang.reflect.Method.invoke(Method.java:498)
    4 frames
  41. IDEA
    AppMain.main
    1. com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
    1 frame