3 Replies Latest reply on Jun 8, 2009 8:01 PM by Bernhard Hurzeler

    org.hibernate.hql.ast.QuerySyntaxException: expecting CLOSE, found 'null'

    Miroslav Vasko Newbie

      Hello,
      I'm in some cases encountering the following exception when using EntityQuery with Seam 2.1.2.CR1 in a seam-gened table. I had to revert back to older 2.1.2-SNAPSHOT where it works always fine.


      INFO   | jvm 1    | 2009/04/16 13:52:20 | javax.servlet.ServletException: /item/ItemList.xhtml @189,58 value="#{itemList.lastFirstResult}": Error reading 'lastFirstResult' on type com.celestica.orders.session.seamgen.ItemList_$$_javassist_seam_17
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:277)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at jcifs.http.NtlmHttpFilter.doFilter(NtlmHttpFilter.java:125)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.jboss.seam.web.RewriteFilter.doFilter(RewriteFilter.java:63)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.jboss.seam.web.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:42)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:390)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:517)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at java.lang.Thread.run(Thread.java:619)
      INFO   | jvm 1    | 2009/04/16 13:52:20 | Caused by: javax.el.ELException: /item/ItemList.xhtml @189,58 value="#{itemList.lastFirstResult}": Error reading 'lastFirstResult' on type com.celestica.orders.session.seamgen.ItemList_$$_javassist_seam_17
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:76)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at javax.faces.component.UIParameter.getValue(UIParameter.java:167)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.jboss.seam.ui.util.ViewUrlBuilder.addParameter(ViewUrlBuilder.java:43)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.jboss.seam.ui.component.UISeamCommandBase.getUrl(UISeamCommandBase.java:56)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.jboss.seam.ui.renderkit.LinkRendererBase.doEncodeBegin(LinkRendererBase.java:26)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.jboss.seam.ui.util.cdk.RendererBase.encodeBegin(RendererBase.java:79)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:813)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at javax.faces.component.UIComponent.encodeAll(UIComponent.java:934)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at javax.faces.component.UIComponent.encodeAll(UIComponent.java:942)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:592)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:100)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:176)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:109)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      ... 46 more
      INFO   | jvm 1    | 2009/04/16 13:52:20 | Caused by: java.lang.IllegalArgumentException: org.hibernate.hql.ast.QuerySyntaxException: expecting CLOSE, found 'null' near line 1, column 186 [select count(*) from com.celestica.orders.entity.Item item where exists (select item2.name, max(item2.version) from com.celestica.orders.entity.Item item2 where (item.name = item2.name)]
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:616)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:95)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.jboss.seam.persistence.EntityManagerProxy.createQuery(EntityManagerProxy.java:81)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.jboss.seam.framework.EntityQuery.createCountQuery(EntityQuery.java:204)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.jboss.seam.framework.EntityQuery.initResultCount(EntityQuery.java:134)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.jboss.seam.framework.EntityQuery.getResultCount(EntityQuery.java:126)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.jboss.seam.framework.Query.getPageCount(Query.java:206)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.jboss.seam.framework.Query.getLastFirstResult(Query.java:167)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at java.lang.reflect.Method.invoke(Method.java:597)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:32)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:77)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.jboss.seam.transaction.TransactionInterceptor$1.work(TransactionInterceptor.java:97)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.jboss.seam.util.Work.workInTransaction(Work.java:47)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.jboss.seam.transaction.TransactionInterceptor.aroundInvoke(TransactionInterceptor.java:91)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:185)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:103)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at com.celestica.orders.session.seamgen.ItemList_$$_javassist_seam_17.getLastFirstResult(ItemList_$$_javassist_seam_17.java)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at java.lang.reflect.Method.invoke(Method.java:597)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at javax.el.BeanELResolver.getValue(BeanELResolver.java:62)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.jboss.el.parser.AstPropertySuffix.getValue(AstPropertySuffix.java:53)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.jboss.el.parser.AstValue.getValue(AstValue.java:67)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.jboss.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      ... 61 more
      INFO   | jvm 1    | 2009/04/16 13:52:20 | Caused by: org.hibernate.hql.ast.QuerySyntaxException: expecting CLOSE, found 'null' near line 1, column 186 [select count(*) from com.celestica.orders.entity.Item item where exists (select item2.name, max(item2.version) from com.celestica.orders.entity.Item item2 where (item.name = item2.name)]
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:31)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:24)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:59)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:258)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:157)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:111)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:77)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:56)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1623)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:92)
      INFO   | jvm 1    | 2009/04/16 13:52:20 |      ... 99 more
      



      The code for the component is: (I know, the EJBQL could be optimized, but it works satisfactorily)


      @Name("itemList")
      public class ItemList extends EntityQuery<Item> {
      
          private static final long serialVersionUID = -5655527700720771957L;
      
          private static final String EJBQL = "select item from Item item where exists " + 
                     "(select item2.name, max(item2.version) from Item item2 where (item.name = item2.name) group by item2.name having " + 
                     "(item.name = item2.name) and (item.version = max(item2.version)))";
      
           private static final String[] RESTRICTIONS = {
                     "lower(item.name) like concat(lower(#{itemList.item.name}),'%')",
                     "lower(item.description) like concat(lower(#{itemList.item.description}),'%')",
                     "lower(item.unit) like concat(lower(#{itemList.item.unit}),'%')",
                     "item.active = #{itemList.item.active}", };
      
           private Item item = new Item();
      
           public ItemList() {
               item.setActive(true);
                setEjbql(EJBQL);
                setRestrictionExpressionStrings(Arrays.asList(RESTRICTIONS));
                setMaxResults(((MaxResultsSelector) Component.getInstance("maxResultsSelector")).getValue());
           }
      
           public Item getItem() {
                return item;
           }
      }
      


      The generated query is obviously incorrect. I'm I doing something wrong or is this a seam bug?
      Thank you very much.