我正在尝试使用Hibernate调用特定查询,但出现错误
java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: ( near line 1, column 26 [select t.orderState from (from com.amtrust.decisionTree.model.TrRepairOrder where claimNumber='SERCON201474') t where t.orderState = 'Cancel' and not exists ( select 1 from (from com.amtrust.decisionTree.model.TrRepairOrder where claimNumber='SERCON201474') tt where tt.id > t.id and tt.orderState <> t.orderState)]
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:133)
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:157)
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:164)
at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:670)
at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:23)
at sun.reflect.GeneratedMethodAccessor41.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:350)
at com.sun.proxy.$Proxy100.createQuery(Unknown Source)
at sun.reflect.GeneratedMethodAccessor41.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:305)
at com.sun.proxy.$Proxy100.createQuery(Unknown Source)
任何人都可以帮助我解决此问题。请找到以下代码部分:
String isCancelStatusQuery =
"select t.orderState from (from TrRepairOrder where claimNumber='" + createOrder.getClaimId() + "') t" +
" where t.orderState = 'Cancel'" +
" and not exists (" +
" select 1 from (from TrRepairOrder where claimNumber='" + createOrder.getClaimId() + "') tt" +
" where tt.id > t.id and tt.orderState <> t.orderState" +
")";
List<Boolean> isCancelStatus = entityManager.createQuery( isCancelStatusQuery ).getResultList();
select t.orderState from (select * from TrRepairOrder where claimNumber='SERCON201474') t where t.orderState = 'Cancel' and not exists ( select 1 from (select * from TrRepairOrder where claimNumber='SERCON201474') tt where tt.id > t.id and tt.orderState <> t.orderState)