2 Replies Latest reply on Oct 23, 2006 6:54 AM by Andrew Dale

    totally weird error: org.hibernate.hql.ast.tree.FromClause.f

    John Singleton Newbie

      Okay, I'm totally lost here:

      Whenever the following code is executed I get this error:

      org.hibernate.hql.ast.tree.FromClause.findIntendedAliasedFromElementBasedOnCrazyJPARequirements(FromClause.java:120)

      What the heck does this mean? My HQL is perfectly valid!

      public void endSession()
       {
       /*
       * first get all writing sessions with a null end date.
       */
       String userid = context.getCallerPrincipal().getName();
      
       List result = em.createQuery( "select w from WritingSession w where w.whatProject.projectOwner=:whatName and w.whatProject.defaultProject=true and w.sessionEnd=null order by id desc")
       .setParameter("whatName", userid).getResultList();
      
       if(result!=null || result.size()!=0)
       {
       WritingSession theOpenSession = (WritingSession)result.get(result.size()-1);
       theOpenSession.setSessionEnd(new Date());
       em.merge(theOpenSession);
       }
      
       //otherwise there are no sessions to close.
       }
      

      JLS


        • 1. Re: totally weird error: org.hibernate.hql.ast.tree.FromClau
          wink rie Newbie

          I get the same exception when I patched rc9,
          and it can work well in rc8.


          em.createQuery("select sue.sysCode.codeId, " +
          "sue.password, sue.sysCode.state, sue.sysCode.codeContent, sue.employeeId " +
          "from SysUserEntity sue " +
          "where sue.sysCode.codeName = ?1")
          .setParameter(1, loginName)
          .getResultList();



          javax.ejb.EJBException: java.lang.NullPointerException
          at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:69)
          at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83)
          at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:197)
          at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
          at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
          at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
          at org.jboss.ejb3.stateful.StatefulInstanceInterceptor.invoke(StatefulInstanceInterceptor.java:83)
          at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
          at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78)
          at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:131)
          at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
          at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
          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.stateful.StatefulContainer.dynamicInvoke(StatefulContainer.java:319)
          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:828)
          at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:681)
          at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:358)
          at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:412)
          at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:239)
          at org.jboss.remoting.RemoteClientInvoker.invoke(RemoteClientInvoker.java:190)
          at org.jboss.remoting.Client.invoke(Client.java:525)
          at org.jboss.remoting.Client.invoke(Client.java:488)
          at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:55)
          at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
          at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:61)
          at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
          at org.jboss.aspects.security.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:55)
          at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
          at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:77)
          at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
          at org.jboss.ejb3.stateful.StatefulRemoteProxy.invoke(StatefulRemoteProxy.java:133)
          at $Proxy251.login(Unknown Source)
          at ndtv.boss.common.web.security.SecurityDelegate.login(SecurityDelegate.java:41)
          at ndtv.boss.common.web.security.Login_do.doPost(Login_do.java:49)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
          at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
          at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
          at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
          at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
          at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
          at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
          at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
          at java.lang.Thread.run(Thread.java:595)
          Caused by: java.lang.NullPointerException
          at org.hibernate.hql.ast.tree.FromClause.findIntendedAliasedFromElementBasedOnCrazyJPARequirements(FromClause.java:120)
          at org.hibernate.hql.ast.tree.FromClause.containsClassAlias(FromClause.java:247)
          at org.hibernate.hql.ast.tree.FromClause.isFromElementAlias(FromClause.java:135)
          at org.hibernate.hql.ast.HqlSqlWalker.isNonQualifiedPropertyRef(HqlSqlWalker.java:474)
          at org.hibernate.hql.antlr.HqlSqlBaseWalker.propertyRef(HqlSqlBaseWalker.java:1101)
          at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectExpr(HqlSqlBaseWalker.java:1881)
          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.(HQLQueryPlan.java:77)
          at org.hibernate.engine.query.HQLQueryPlan.(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:127)
          at ndtv.boss.service.security.SecurityBean.login(SecurityBean.java:110)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:585)
          at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
          at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
          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.ExtendedPersistenceContextPropagationInterceptor.invoke(ExtendedPersistenceContextPropagationInterceptor.java:57)
          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:197)
          at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
          at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
          at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
          at org.jboss.ejb3.stateful.StatefulInstanceInterceptor.invoke(StatefulInstanceInterceptor.java:83)
          at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
          at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78)
          at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:131)
          at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
          at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
          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.stateful.StatefulContainer.dynamicInvoke(StatefulContainer.java:319)
          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:828)
          at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:681)
          at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:358)
          at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:412)
          at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:239)


          • 2. Re: totally weird error: org.hibernate.hql.ast.tree.FromClau
            Andrew Dale Newbie

            I also had this problem after upgrading to the latest release of Hibernate (3.2.0GA). I was experiencing the this exception when trying query a single table inheritence structure.

            The following query did not work

            Query tmpQuery = mEntityManager.createQuery("SELECT DISTINCT e.expression FROM TargetEntity " +
             "t INNER JOIN t.expressionTargets e LEFT OUTER JOIN FETCH e.expression.restrictions r " +
             "JOIN FETCH r.expressionTargets f JOIN FETCH f.targetEntity " +
             "WHERE t.id = :pk AND e.expression.class = Rule").setParameter("pk", 1);
            


            but the following one did

            Query tmpQuery = mEntityManager.createQuery("SELECT DISTINCT e.expression FROM TargetEntity " +
             "t INNER JOIN t.expressionTargets e LEFT OUTER JOIN FETCH e.expression.restrictions r " +
             "JOIN FETCH r.expressionTargets f JOIN FETCH f.targetEntity " +
             "WHERE t.id = :pk AND e.expression.class = 'rule'").setParameter("pk", 1);
            


            I had to quote the discriminator value in the query, if this was not done it caused a NPE.

            Cheers,

            Andy