Just upgraded from `Hibernate 5.1.0 Final` to `Hibernate 5.2.2 Final` and got following produced JPQL from hibernate.
We are using ` JPA criteria` and mainly we do not write `free text` Invalid path: 'generatedAlias2 . It seems that the cause for the error is using imgLocation' ` treat` function:
The following code can reproduce the issue {quote}
Join<A, B> somefield= root.join(A.image, JoinType.INNER); Predicate notEmpty = cb.notEqual(cb.treat(somefield,B.class).get(B_.somefield), "");
{quote}
We are using `JPA criteria` and mainly we do not write `free text`. It seems that the cause for the error is using `treat` function: removing the use of `treat` function makes the issue disappear
{quote}SELECT count(generatedAlias0) FROM com.centure.core.matching.entity.ImageForMatch AS generatedAlias0 INNER JOIN generatedAlias0.image AS generatedAlias1 WHERE (generatedAlias2.imgLocation<>:param0) AND (generatedAlias3.photographerName IS NOT NULL) AND (generatedAlias3.category=:param1) AND (generatedAlias0.level=1){quote}
It is clear that something went wrong and there generatedAlias2 and generatedAlias3 does not exist....
bq. Sep 08, 2016 12:49:08 PM org.apache.catalina.core.StandardWrapperValve invoke SEVERE: Servlet.service() for servlet [spring] in context with path [/ centure-serverside ] threw exception [Request processing failed; nested exception is org.springframework.dao.InvalidDataAccessApiUsageException: org.hibernate.hql.internal.ast.QuerySyntaxException: Invalid path: 'generatedAlias2.imgLocation' [select count(generatedAlias0) from com.centure.core.matching.entity.ImageForMatch as generatedAlias0 inner join generatedAlias0.image as generatedAlias1 where ( generatedAlias2.imgLocation<>:param0 ) and ( generatedAlias3.photographerName is not null ) and ( generatedAlias3.category=:param1 ) and ( generatedAlias0.level=1 )]; nested exception is java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: Invalid path: 'generatedAlias2.imgLocation' [select count(generatedAlias0) from com.centure.core.matching.entity.ImageForMatch as generatedAlias0 inner join generatedAlias0.image as generatedAlias1 where ( generatedAlias2.imgLocation<>:param0 ) and ( generatedAlias3.photographerName is not null ) and ( generatedAlias3.category=:param1 ) and ( generatedAlias0.level=1 )]] with root cause org.hibernate.hql.internal.ast.QuerySyntaxException: Invalid path: 'generatedAlias2.imgLocation' [select count(generatedAlias0) from com.centure.core.matching.entity.ImageForMatch as generatedAlias0 inner join generatedAlias0.image as generatedAlias1 where ( generatedAlias2.imgLocation<>:param0 ) and ( generatedAlias3.photographerName is not null ) and ( generatedAlias3.category=:param1 ) and ( generatedAlias0.level=1 )] at org.hibernate.hql.internal.ast.QuerySyntaxException.convert(QuerySyntaxException.java:74) at org.hibernate.hql.internal.ast.ErrorCounter.throwQueryException(ErrorCounter.java:91) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:268) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:190) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:142) at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:115) at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:77) at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:152) at org.hibernate.internal.AbstractSharedSessionContract.getQueryPlan(AbstractSharedSessionContract.java:526) at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:628) at org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:3285) at org.hibernate.query.criteria.internal.CriteriaQueryImpl$1.buildCompiledQuery(CriteriaQueryImpl.java:318) at org.hibernate.query.criteria.internal.compile.CriteriaCompiler.compile(CriteriaCompiler.java:127) at org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:3578) at org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:203) at sun.reflect.GeneratedMethodAccessor763.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:298) at com.sun.proxy.$Proxy129.createQuery(Unknown Source) at org.springframework.data.jpa.repository.support.SimpleJpaRepository.getCountQuery(SimpleJpaRepository.java:685) at org.springframework.data.jpa.repository.support.SimpleJpaRepository.getCountQuery(SimpleJpaRepository.java:659) at org.springframework.data.jpa.repository.support.SimpleJpaRepository.count(SimpleJpaRepository.java:495) at sun.reflect.GeneratedMethodAccessor1041.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.executeMethodOn(RepositoryFactorySupport.java:503) at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:488) at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:460) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:61) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:280) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:133) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213) at com.sun.proxy.$Proxy146.count(Unknown Source) at sun.reflect.GeneratedMethodAccessor1616.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java) at java.lang.reflect.Method.invoke(Method.java:498) at org.zeroturnaround.javarebel.integration.util.ReloadingProxyFactory$ReloadingMethodHandler.invoke(SourceFile:74) at com.sun.proxy.$Proxy146.count(Unknown Source) at sun.reflect.GeneratedMethodAccessor1616.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java) at java.lang.reflect.Method.invoke(Method.java:498) at org.zeroturnaround.javarebel.integration.util.ReloadingProxyFactory$ReloadingMethodHandler.invoke(SourceFile:74) at com.sun.proxy.$Proxy146.count(Unknown Source) at com.centure.core.m |
|