QueryException异常错误

时间:2014-12-31 14:07:48

标签: jpa compiler-errors eclipselink jpql

我尝试从我的表格中获得一个程序列表" Program"左连接。以前每件事都运行正常,但是当我重新启动计算机时出现此错误

  

引起:异常[EclipseLink-6076](Eclipse Persistence Services    - 2.5.0.v20130507-3faac2b):org.eclipse.persistence.exceptions.QueryException异常   描述:对象比较只能用于   OneToOneMappings。其他映射比较必须通过   查询键或直接属性级别比较。制图:   [org.eclipse.persistence.mappings.DirectToFieldMapping [idIntervention - > programme.IDINTERVENTION]]   表达式:[查询密钥idIntervention Base entities.Programme]   查询:ReadAllQuery(referenceClass = Program jpql =" select from from   计划p左加入干预我对p.idInvention   = i.PROGRAMME_IDINTERVENTION其中p.operationSuivante< =:d ORDER BY p.operationSuivante ASC")at   org.eclipse.persistence.exceptions.QueryException.unsupportedMappingForObjectComparison(QueryException.java:1164)     在   org.eclipse.persistence.mappings.DatabaseMapping.buildObjectJoinExpression(DatabaseMapping.java:271)     在   org.eclipse.persistence.internal.expressions.RelationExpression.normalize(RelationExpression.java:805)     在   org.eclipse.persistence.expressions.ExpressionBuilder.normalize(ExpressionBuilder.java:265)     在   org.eclipse.persistence.internal.expressions.SQLSelectStatement.normalize(SQLSelectStatement.java:1414)     在   org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.buildNormalSelectStatement(ExpressionQueryMechanism.java:549)     在   org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.prepareSelectAllRows(ExpressionQueryMechanism.java:1708)     在   org.eclipse.persistence.queries.ReadAllQuery.prepareSelectAllRows(ReadAllQuery.java:785)     在   org.eclipse.persistence.queries.ReadAllQuery.prepare(ReadAllQuery.java:716)     在   org.eclipse.persistence.queries.DatabaseQuery.checkPrepare(DatabaseQuery.java:661)     在   org.eclipse.persistence.queries.ObjectLevelReadQuery.checkPrepare(ObjectLevelReadQuery.java:888)     在   org.eclipse.persistence.queries.DatabaseQuery.checkPrepare(DatabaseQuery.java:613)     在   org.eclipse.persistence.internal.jpa.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:194)     在   org.eclipse.persistence.internal.jpa.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:116)     在   org.eclipse.persistence.internal.jpa.EJBQueryImpl。(EJBQueryImpl.java:102)     在   org.eclipse.persistence.internal.jpa.EJBQueryImpl。(EJBQueryImpl.java:86)     在   org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1583)     在   com.sun.enterprise.container.common.impl.EntityManagerWrapper.createQuery(EntityManagerWrapper.java:456)     在session.ProgrammeFacade.findByDate(ProgrammeFacade.java:179)at at   sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at   sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)     在   sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)     在java.lang.reflect.Method.invoke(Method.java:483)at   org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1081)     在   org.glassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:1153)     在   com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:4695)     at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:630)     在   com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)     在com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:582)at   org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:46)     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at   sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)     在   sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)     在java.lang.reflect.Method.invoke(Method.java:483)at   com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:883)     在   com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)     在com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:582)at   com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doCall(SystemInterceptorProxy.java:163)     在   com.sun.ejb.containers.interceptors.SystemInterceptorProxy.aroundInvoke(SystemInterceptorProxy.java:140)     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at   sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)     在   sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)     在java.lang.reflect.Method.invoke(Method.java:483)at   com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:883)     在   com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)     在   com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:369)     在   com.sun.ejb.containers.BaseContainer .__截距(BaseContainer.java:4667)     在   com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:4655)     在   com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:212)     ... 79更多

1 个答案:

答案 0 :(得分:0)

JPQL与SQL语言不同。对实体之间的关联进行连接。它不需要ON子句。 JPQL从不使用列名。始终是实体和字段/ prioperty名称。

有效的JPQL查询(假设关联存在,但您没有发布实体)将类似于:

select  p from Programme p 
left join p.intervention i
where p.operationSuivante <= :d 
order by p.operationSuivante asc

但是,由于您从未在查询中的任何位置使用i,因此此连接完全无用。