JPA EclipseLink-表达式不是有效的条件表达式

时间:2019-04-11 13:18:17

标签: spring-boot jpa windows-7 eclipselink language-packs

尽管此查询没有任何问题,但eclipselink会引发此异常。

  

[34,130]表达式不是有效的条件表达式。

我正在尝试在Windows 7中使用Jpa / eclipselink运行Spring Boot。

将系统语言更改为土耳其语时会发生问题。

为什么eclipselink在使用土耳其语的操作系统上不起作用?当我将系统语言更改为英语时,效果很好。

请有人帮我。

查询:

return em.createQuery("select c from Orderdetail c where c.status=1 and c.triggertime > 0 and c.printstatus = 0 and c.idorder.idorderstatus.id in (1, 4)").setHint(QueryHints.REFRESH, HintValues.TRUE).getResultList();

这是另一个查询解析错误。完整日志

    Exception Description: Syntax error parsing [select c from Orderdetail c where c.status=1 and c.triggertime > 0 and c.printstatus = 0 and c.idorder.idorderstatus.id in (1, 4)]. 
[34, 131] The expression is not a valid conditional expression.
    at org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:367) ~[spring-orm-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
    at org.springframework.orm.jpa.DefaultJpaDialect.translateExceptionIfPossible(DefaultJpaDialect.java:127) ~[spring-orm-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:527) ~[spring-orm-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
    at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:61) ~[spring-tx-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
    at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:242) ~[spring-tx-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:153) ~[spring-tx-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185) ~[spring-aop-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:688) ~[spring-aop-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
    at tr.com.abeja.acservice.repository.DictionariesRepository$$EnhancerBySpringCGLIB$$9c377301.findTriggeredOrderDetails(<generated>) ~[classes!/:3.2.1]
    at tr.com.abeja.acservice.service.DictsController.findAndPrintTriggeredOrderDetails(DictsController.java:887) ~[classes!/:3.2.1]
    at tr.com.abeja.acservice.controller.DictsResource.updateTimerProductsPrice(DictsResource.java:48) ~[classes!/:3.2.1]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_202]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_202]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_202]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_202]
    at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:84) ~[spring-context-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
    at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) ~[spring-context-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [na:1.8.0_202]
    at java.util.concurrent.FutureTask.runAndReset(Unknown Source) [na:1.8.0_202]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(Unknown Source) [na:1.8.0_202]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source) [na:1.8.0_202]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [na:1.8.0_202]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [na:1.8.0_202]
    at java.lang.Thread.run(Unknown Source) [na:1.8.0_202]
Caused by: java.lang.IllegalArgumentException: An exception occurred while creating a query in EntityManager: 
Exception Description: Syntax error parsing [select c from Orderdetail c where c.status=1 and c.triggertime > 0 and c.printstatus = 0 and c.idorder.idorderstatus.id in (1, 4)]. 
[34, 131] The expression is not a valid conditional expression.
    at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1746) ~[eclipselink-2.7.4.jar!/:2.7.4.v20190115-ad5b7c6b2a]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_202]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_202]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_202]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_202]
    at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:350) ~[spring-orm-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
    at com.sun.proxy.$Proxy68.createQuery(Unknown Source) ~[na:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_202]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_202]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_202]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_202]
    at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:305) ~[spring-orm-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
    at com.sun.proxy.$Proxy68.createQuery(Unknown Source) ~[na:na]
    at tr.com.abeja.acservice.repository.DictionariesRepository.findTriggeredOrderDetails(DictionariesRepository.java:857) ~[classes!/:3.2.1]
    at tr.com.abeja.acservice.repository.DictionariesRepository$$FastClassBySpringCGLIB$$5a490717.invoke(<generated>) ~[classes!/:3.2.1]
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) ~[spring-core-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:746) ~[spring-aop-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) ~[spring-aop-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139) ~[spring-tx-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
    ... 18 common frames omitted
Caused by: org.eclipse.persistence.exceptions.JPQLException: 
Exception Description: Syntax error parsing [select c from Orderdetail c where c.status=1 and c.triggertime > 0 and c.printstatus = 0 and c.idorder.idorderstatus.id in (1, 4)]. 
[34, 131] The expression is not a valid conditional expression.
    at org.eclipse.persistence.internal.jpa.jpql.HermesParser.buildException(HermesParser.java:157) ~[eclipselink-2.7.4.jar!/:2.7.4.v20190115-ad5b7c6b2a]
    at org.eclipse.persistence.internal.jpa.jpql.HermesParser.validate(HermesParser.java:336) ~[eclipselink-2.7.4.jar!/:2.7.4.v20190115-ad5b7c6b2a]
    at org.eclipse.persistence.internal.jpa.jpql.HermesParser.populateQueryImp(HermesParser.java:280) ~[eclipselink-2.7.4.jar!/:2.7.4.v20190115-ad5b7c6b2a]
    at org.eclipse.persistence.internal.jpa.jpql.HermesParser.buildQuery(HermesParser.java:165) ~[eclipselink-2.7.4.jar!/:2.7.4.v20190115-ad5b7c6b2a]
    at org.eclipse.persistence.internal.jpa.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:142) ~[eclipselink-2.7.4.jar!/:2.7.4.v20190115-ad5b7c6b2a]
    at org.eclipse.persistence.internal.jpa.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:118) ~[eclipselink-2.7.4.jar!/:2.7.4.v20190115-ad5b7c6b2a]
    at org.eclipse.persistence.internal.jpa.EJBQueryImpl.<init>(EJBQueryImpl.java:104) ~[eclipselink-2.7.4.jar!/:2.7.4.v20190115-ad5b7c6b2a]
    at org.eclipse.persistence.internal.jpa.EJBQueryImpl.<init>(EJBQueryImpl.java:88) ~[eclipselink-2.7.4.jar!/:2.7.4.v20190115-ad5b7c6b2a]
    at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1744) ~[eclipselink-2.7.4.jar!/:2.7.4.v20190115-ad5b7c6b2a]
    ... 36 common frames omitted

1 个答案:

答案 0 :(得分:1)

[已解决]

花了几个小时的调试之后,我找到了此异常的原因。

LSS:HermesParser中发生异常,这是eclipselink中的查询解析器。从那里开始,我找到了将jpql的inandorlike等部分转换为大写的代码。

我的查询的一部分(无法解析)。

and c.idorder.idorderstatus.id in (1, 4)

这里andin转换为大写ANDIN。问题是,在土耳其语中,i字母的大写字母是İ(点缀I),因此in的大写字母是İN,这是不正确的表达式。如果操作系统语言为土耳其语,则大写方法会将i转换为İ。那是问题。

我事先将jpql中的所有小写字母都更改为大写,并解决了问题。

希望它可以帮助遇到此问题的其他人