1 Reply Latest reply on Mar 20, 2012 1:59 PM by Qingxin Yi

    How to write a left outer join in EJBQL?

    Qingxin Yi Newbie

      Hi,

       

      I'm trying to write a left outer join query in EJBQL.  But + is not recognized by Hibernate.  Can someone help?  Thanks!

            public String getEjbql() {
       return "select NEW gov.dot.marad.mscs.entity.EdrRow(edr.edrId,edr.reportingYear, edr.employerName, edr.refEmploymentType.employmentType, edr.beginDate, edr.endDate, edrStatus.refRequestStatus.status, edrStatus.refRequestStatus.statusId, refRequestStatus.refRole.roleId, contractStatus.refContractStatus.statusId) " +
       "from gov.dot.marad.mscs.entity.Edr as edr, gov.dot.marad.mscs.entity.EdrStatus as edrStatus, gov.dot.marad.mscs.entity.RefRequestStatus as refRequestStatus, gov.dot.marad.mscs.entity.ContractStatus as contractStatus where edr.edrId = edrStatus.edr.edrId " +
       "and edrStatus.createdDate = (select max(edrStatus2.createdDate) from EdrStatus edrStatus2 " +
       "where edrStatus.edr.edrId = edrStatus2.edr.edrId) " +
       "and edr.studentProfile.studentId=#{studentProfileHome.instance.studentId} " +
       "and edrStatus.refRequestStatus.statusId = refRequestStatus.statusId " +
       "and edr.edr_id = contractStatus.edr.edrId(+) ";
      

       

      Here is the error log:

       

      12:17:15,524 ERROR [PARSER] line 1:875: unexpected token: )
      12:17:15,524 ERROR [PARSER] line 1:877: unexpected token: null
      12:17:15,540 ERROR [PARSER] line 1:877: expecting CLOSE, found 'null'
      12:17:15,556 ERROR [STDERR] Mar 19, 2012 12:17:15 PM com.sun.facelets.FaceletViewHandler handleRenderException
      SEVERE: Error Rendering View[/secure/EDRList.xhtml]
      javax.faces.el.EvaluationException: /secure/EDRListTable.xhtml @15,50 value="#{edrList.resultList}": Exception getting value of property resultList of base of type : gov.dot.marad.mscs.entity.EdrList_$$_javassist_1067
      
       at com.sun.facelets.el.LegacyValueBinding.getValue(LegacyValueBinding.java:60)
       at javax.faces.component.UIData.getValue(UIData.java:1019)
       at org.ajax4jsf.component.SequenceDataAdaptor.getDataModel(SequenceDataAdaptor.java:70)
       at org.ajax4jsf.component.SequenceDataAdaptor.createDataModel(SequenceDataAdaptor.java:64)
       at org.ajax4jsf.component.UIDataAdaptor.getExtendedDataModel(UIDataAdaptor.java:566)
       at org.ajax4jsf.component.UIDataAdaptor.walk(UIDataAdaptor.java:968)
       at org.richfaces.renderkit.AbstractRowsRenderer.encodeRows(AbstractRowsRenderer.java:104)
       at org.richfaces.renderkit.AbstractRowsRenderer.encodeChildren(AbstractRowsRenderer.java:136)
       at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:524)
       at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:282)
       at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:262)
       at org.richfaces.renderkit.html.PanelRenderer.doEncodeChildren(PanelRenderer.java:199)
       at org.richfaces.renderkit.html.PanelRenderer.doEncodeChildren(PanelRenderer.java:194)
       at org.ajax4jsf.renderkit.RendererBase.encodeChildren(RendererBase.java:121)
       at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:524)
       at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:282)
       at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:262)
       at org.richfaces.renderkit.html.PanelRenderer.doEncodeChildren(PanelRenderer.java:199)
       at org.richfaces.renderkit.html.PanelRenderer.doEncodeChildren(PanelRenderer.java:194)
       at org.ajax4jsf.renderkit.RendererBase.encodeChildren(RendererBase.java:121)
       at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:524)
       at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:282)
       at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:262)
       at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:284)
       at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:262)
       at org.richfaces.renderkit.html.PanelRenderer.doEncodeChildren(PanelRenderer.java:199)
       at org.richfaces.renderkit.html.PanelRenderer.doEncodeChildren(PanelRenderer.java:194)
       at org.ajax4jsf.renderkit.RendererBase.encodeChildren(RendererBase.java:121)
       at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:524)
       at com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:244)
       at com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:249)
       at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:573)
       at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
       at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:216)
       at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:384)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:138)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:63)
       at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:60)
       at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
       at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
       at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
       at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:57)
       at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
       at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:79)
       at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
       at org.jboss.seam.web.SeamFilter.doFilter(SeamFilter.java:84)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
       at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at gov.dot.marad.security.web.filter.AuthenticationFilter.doFilter(Unknown Source)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       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.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
       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.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
       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: javax.faces.el.EvaluationException: Bean: gov.dot.marad.mscs.entity.EdrList_$$_javassist_1067, property: resultList
       at org.apache.myfaces.el.PropertyResolverImpl.getProperty(PropertyResolverImpl.java:442)
       at org.apache.myfaces.el.PropertyResolverImpl.getValue(PropertyResolverImpl.java:82)
       at com.sun.facelets.el.LegacyELContext$LegacyELResolver.getValue(LegacyELContext.java:141)
       at com.sun.el.parser.AstValue.getValue(AstValue.java:125)
       at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:195)
       at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
       at com.sun.facelets.el.LegacyValueBinding.getValue(LegacyValueBinding.java:56)
       ... 74 more
      Caused by: java.lang.reflect.InvocationTargetException
       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:592)
       at org.apache.myfaces.el.PropertyResolverImpl.getProperty(PropertyResolverImpl.java:438)
       ... 80 more
      Caused by: java.lang.IllegalArgumentException: org.hibernate.hql.ast.QuerySyntaxException: unexpected token: ) near line 1, column 875 [select NEW gov.dot.marad.mscs.entity.EdrRow(edr.edrId,edr.reportingYear, edr.employerName, edr.refEmploymentType.employmentType, edr.beginDate, edr.endDate, edrStatus.refRequestSt
      12:17:15,556 ERROR [STDERR] atus.status, edrStatus.refRequestStatus.statusId, refRequestStatus.refRole.roleId, contractStatus.refContractStatus.statusId) from gov.dot.marad.mscs.entity.Edr as edr, gov.dot.marad.mscs.entity.EdrStatus as edrStatus, gov.dot.marad.mscs.entity.RefRequestStatus as refRequestStatus, gov.dot.marad.mscs.entity.ContractStatus as contractStatus where edr.edrId = edrStatus.edr.edrId and edrStatus.createdDate = (select max(edrStatus2.createdDate) from gov.dot.marad.mscs.entity.EdrStatus edrStatus2 where edrStatus.edr.edrId = edrStatus2.edr.edrId) and edr.studentProfile.studentId=:el1 and edrStatus.refRequestStatus.statusId = refRequestStatus.statusId and edr.edr_id = contractStatus.edr.edrId(+) ]
       at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:634)
       at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:95)
       at org.jboss.seam.persistence.EntityManagerProxy.createQuery(EntityManagerProxy.java:72)
       at org.jboss.seam.framework.EntityQuery.createQuery(EntityQuery.java:105)
       at org.jboss.seam.framework.EntityQuery.getResultList(EntityQuery.java:41)
       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:592)
       at org.jboss.seam.util.Reflections.invoke(Reflections.java:20)
       at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:57)
       at org.jboss.seam.interceptors.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:34)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
       at org.jboss.seam.interceptors.TransactionInterceptor$1.work(TransactionInterceptor.java:32)
       at org.jboss.seam.util.Work.workInTransaction(Work.java:37)
       at org.jboss.seam.interceptors.TransactionInterceptor.aroundInvoke(TransactionInterceptor.java:27)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
       at org.jboss.seam.interceptors.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:27)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
       at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:103)
       at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:151)
       at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:87)
       at gov.dot.marad.mscs.entity.EdrList_$$_javassist_1067.getResultList(EdrList_$$_javassist_1067.java)
       ... 85 more
      Caused by: org.hibernate.hql.ast.QuerySyntaxException: unexpected token: ) near line 1, column 875 [select NEW gov.dot.marad.mscs.entity.EdrRow(edr.edrId,edr.reportingYear, edr.employerName, edr.refEmploymentType.employmentType, edr.beginDate, edr.endDate, edrStatus.refRequestStatus.status, edrStatus.refRequestStatus.statusId, refRequestStatus.refRole.roleId, contractStatus.refContractStatus.statusId) from gov.dot.marad.mscs.entity.Edr as edr, gov.dot.marad.mscs.entity.EdrStatus as edrStatus, gov.dot.marad.mscs.entity.RefRequestStatus as refRequestStatus, gov.dot.marad.mscs.entity.ContractStatus as contractStatus where edr.edrId = edrStatus.edr.edrId and edrStatus.createdDate = (select max(edrStatus2.createdDate) from gov.dot.marad.mscs.entity.EdrStatus edrStatus2 where edrStatus.edr.edrId = edrStatus2.edr.edrId) and edr.studentProfile.studentId=:el1 and edrStatus.refRequestStatus.statusId = refRequestStatus.statusId and edr.edr_id = contractStatus.edr.edrId(+) ]
       at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:31)
       at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:24)
       at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:59)
       at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:258)
       at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:157)
       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)
       ... 107 more