我在以下HQL查询中出错:

         em.createQuery(
            "SELECT new com.magenta.sovereign.entity.view.ThirdPartyReportView(" +
                    "e.id, " +
                    "e.vehicleRegistrationNumber, " +
                    "e.driverName, " +
                    "e.thirdPartyAssignee.firstName, " +
                    "e.thirdPartyAssignee.middleName, " +
                    "e.thirdPartyAssignee.lastName, " +
                    "e.totalDamageCost, " +
                    "e.date, " +
                    "tp.regNumber, " +
                    "tp.name, " +
                    "tp.thirdPartyFault, " +
                    "tp.settlementDetails, " +
                    "e.claimStatus, " +
                    "e.currentStatus," +
                    "(SELECT max(invoice1.date) FROM Invoice invoice1 WHERE invoice1.claim = e )  " +

            ") FROM Claim e left join e.thirdParties tp")
            .setMaxResults(10);


如果我从查询中删除子选择,则一切正常

"(SELECT max(invoice1.date) FROM Invoice invoice1 WHERE invoice1.claim = e )  "


但是对于子查询,我有以下错误:

  javax.ejb.EJBException: java.lang.NullPointerException
              at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:63)
              at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83)
              at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:95)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
              at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:110)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:304)
              at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:106)
              at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82)
              at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:809)
              at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:608)
              at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:406)
              at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:173)
          Caused by: java.lang.NullPointerException
              at org.hibernate.hql.ast.tree.FromClause.findIntendedAliasedFromElementBasedOnCrazyJPARequirements(FromClause.java:120)
              at org.hibernate.hql.ast.tree.FromClause.getFromElement(FromClause.java:107)
              at org.hibernate.hql.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:81)
              at org.hibernate.hql.ast.tree.FromClause.addFromElement(FromClause.java:70)
              at org.hibernate.hql.ast.HqlSqlWalker.createFromElement(HqlSqlWalker.java:255)
              at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3056)
              at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:2945)
              at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:688)
              at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:544)
              at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectExpr(HqlSqlBaseWalker.java:2014)
              at org.hibernate.hql.antlr.HqlSqlBaseWalker.aliasedSelectExpr(HqlSqlBaseWalker.java:2057)
              at org.hibernate.hql.antlr.HqlSqlBaseWalker.constructor(HqlSqlBaseWalker.java:2226)
              at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectExpr(HqlSqlBaseWalker.java:1952)
              at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectExprList(HqlSqlBaseWalker.java:1825)
              at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectClause(HqlSqlBaseWalker.java:1394)
              at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:553)
              at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:281)
              at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:229)
              at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:228)
              at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:160)
              at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:111)
              at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:77)
              at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:56)
              at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72)
              at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
              at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
              at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1623)
              at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:92)
              at org.jboss.ejb3.entity.TransactionScopedEntityManager.createQuery(TransactionScopedEntityManager.java:134)
              at com.magenta.sovereign.ejb.ReportingServiceBean.getThirdPartyReportView(ReportingServiceBean.java:72)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
              at java.lang.reflect.Method.invoke(Method.java:616)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
              at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
              at com.magenta.sovereign.ejb.AbstractBean.aroundInvoke(AbstractBean.java:63)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
              at java.lang.reflect.Method.invoke(Method.java:616)
              at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:146)
              at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
              at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:95)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
              at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:110)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:304)
              at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:106)
              at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82)
              at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:809)
              at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:608)
              at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:406)
              at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:173)
              at org.jboss.remoting.MicroRemoteClientInvoker.invoke(MicroRemoteClientInvoker.java:163)
              at org.jboss.remoting.Client.invoke(Client.java:1634)
              at org.jboss.remoting.Client.invoke(Client.java:548)
              at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:62)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:67)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.aspects.security.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:53)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:74)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:107)
              at $Proxy16.getThirdPartyReportView(Unknown Source)
              at com.magenta.sovereign.client.reporting.ThirdPartyReport.getReportData(ThirdPartyReport.java:79)
              at com.magenta.sovereign.client.reporting.AbstractExcelReport.doReport(AbstractExcelReport.java:200)
              at com.magenta.sovereign.client.reporting.AbstractExcelReport.report(AbstractExcelReport.java:163)
              at com.magenta.sovereign.client.view.reporting.ReportingController$11.run(ReportingController.java:168)
              at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:74)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:67)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.aspects.security.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:53)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:74)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:107)
              at $Proxy16.getThirdPartyReportView(Unknown Source)
              at com.magenta.sovereign.client.reporting.ThirdPartyReport.getReportData(ThirdPartyReport.java:79)
              at com.magenta.sovereign.client.reporting.AbstractExcelReport.doReport(AbstractExcelReport.java:200)
              at com.magenta.sovereign.client.reporting.AbstractExcelReport.report(AbstractExcelReport.java:163)
              at com.magenta.sovereign.client.view.reporting.ReportingController$11.run(ReportingController.java:168)


你能描述一下问题吗

最佳答案

此查询失败,出现相同错误

从ArregloCuota中选择一个a.arreglo.deuda.estudio.id =:estudioID和a.arreglo.anulado = FALSE且a.arregloPagoRealizado为NULL且a.arreglo.deuda.id不在(从以下位置选择lu.deuda.id LlamadoListadoPorUsuarioDetalle WHERE lu.listado.gestion.fechaHoraCierre IS NULL)由a.arreglo.id DESC,a.numeroCuota ASC排序

但是添加这项工作

从ArregloCuota的内部联接中选择一个LlamadoListadoPorUsuarioDetalle WHERE lu.listado.gestion.fechaHoraCierre IS NULL)由a.arreglo.id DESC,a.numeroCuota ASC排序

10-04 14:37