Hallo zusammen,
habe einen SQL-Ausdruck der bei einer MySQL-Abfrage einwandfrei funktioniert, versuche ich diesen Ausdruck über den EntityManager abzufragen, erhalte ich allerdings Fehler. Bin nicht sehr erfahren mit Hibernate und bitte um Versändiss und hoffentlich eine brauchbare Antwort.
Hibernate version: Version aus jboss-4.2.0.GA
Code:
Code:
SELECT DISTINCT count(csy.y20gpnum) as anzahl, csy.y20gpnum , csy.lat , csy.lon FROM csy20 AS csy
JOIN (SELECT w94.w94liefn, w94.w94erdav FROM csw94 as w94
JOIN (SELECT w90.w90aufnr, w90.w90artgr, w90.w90kdauf FROM csw90 as w90) AS tab2
WHERE w94.w94aufnr = tab2.w90aufnr AND w94.w94artgr = tab2.w90artgr and tab2.w90kdauf like '00012%' ) AS tab
WHERE csy.y20gpnum = tab.w94liefn AND tab.w94erdav >= '2005-12-01 20:43:00' and tab.w94erdav <= '2006-03-22 20:43:00' group by csy.y20gpnum order by anzahl
Code:
entityManager.createQuery(sql).getResultList();
Full stack trace of any exception that occurs:Code:
12:37:47,804 ERROR [PARSER] line 1:108: unexpected token: (
12:37:47,814 ERROR [PARSER] line 1:144: unexpected token: FROM
12:37:47,814 ERROR [PARSER] line 1:171: unexpected token: (
12:37:47,824 ERROR [PARSER] line 1:221: unexpected token: FROM
12:37:47,854 ERROR [STDERR] 25.08.2007 12:37:47 com.sun.facelets.FaceletViewHandler handleRenderException
SCHWERWIEGEND: Error Rendering View[/gmap.xhtml]
javax.faces.FacesException: javax.el.ELException: /gmap.xhtml @55,78 value="#{gmBean.resultList}": Error reading 'resultList' on type org.javassist.tmp.java.lang.Object_$$_javassist_11
at javax.faces.component.UIData.getValue(UIData.java:585)
at org.ajax4jsf.ajax.repeat.UIRepeat.getDataModel(UIRepeat.java:85)
at org.ajax4jsf.ajax.repeat.UIRepeat.createDataModel(UIRepeat.java:79)
at org.ajax4jsf.ajax.repeat.UIDataAdaptor.getExtendedDataModel(UIDataAdaptor.java:522)
at org.ajax4jsf.ajax.repeat.UIDataAdaptor.walk(UIDataAdaptor.java:917)
at org.richfaces.renderkit.AbstractRowsRenderer.encodeRows(AbstractRowsRenderer.java:103)
at org.richfaces.renderkit.AbstractRowsRenderer.encodeChildren(AbstractRowsRenderer.java:135)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:809)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:271)
at com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:242)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:809)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:892)
at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:577)
at org.ajax4jsf.framework.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
at org.ajax4jsf.framework.ajax.AjaxViewHandler.renderView(AjaxViewHandler.java:233)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:87)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:63)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:46)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:127)
at org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:277)
at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:40)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:63)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:140)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
Caused by: javax.el.ELException: /gmap.xhtml @55,78 value="#{gmBean.resultList}": Error reading 'resultList' on type org.javassist.tmp.java.lang.Object_$$_javassist_11
at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:76)
at javax.faces.component.UIData.getValue(UIData.java:582)
... 54 more
Caused by: javax.ejb.EJBTransactionRolledbackException: org.hibernate.hql.ast.QuerySyntaxException: unexpected token: ( near line 1, column 108 [SELECT DISTINCT count(csy.y20gpnum) as anzahl, csy.y20gpnum , csy.lat , csy.lon FROM csy20 AS csy JOIN ( SELECT w94.w94liefn, w94.w94erdav FROM csw94 as w94 JOIN ( SELECT w90.w90aufnr, w90.w90artgr, w90.w90kdauf FROM csw90 as w90 ) AS tab2 WHERE w94.w94aufnr = tab2.w90aufnr AND w94.w94artgr = tab2.w90artgr and tab2.w90kdauf like '00012%' ) AS tab WHERE csy.y20gpnum = tab.w94liefn AND tab.w94erdav >= '2005-12-01 20:43:00' and tab.w94erdav <= '2006-03-22 20:43:00' group by csy.y20gpnum order by anzahl]
at org.jboss.ejb3.tx.Ejb3TxPolicy.handleInCallerTx(Ejb3TxPolicy.java:87)
at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:130)
at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:195)
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:77)
at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:106)
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.stateful.StatefulContainer.localInvoke(StatefulContainer.java:204)
at org.jboss.ejb3.stateful.StatefulLocalProxy.invoke(StatefulLocalProxy.java:100)
at $Proxy106.getResultList(Unknown Source)
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:597)
at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
at org.jboss.seam.intercept.ClientSideInterceptor$1.proceed(ClientSideInterceptor.java:72)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
at org.jboss.seam.ejb.RemoveInterceptor.aroundInvoke(RemoveInterceptor.java:41)
at org.jboss.seam.intercept.SeamI
12:37:47,864 ERROR [STDERR] nvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.core.SynchronizationInterceptor.aroundInvoke(SynchronizationInterceptor.java:32)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:106)
at org.jboss.seam.intercept.ClientSideInterceptor.invoke(ClientSideInterceptor.java:50)
at org.javassist.tmp.java.lang.Object_$$_javassist_11.getResultList(Object_$$_javassist_11.java)
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:597)
at javax.el.BeanELResolver.getValue(BeanELResolver.java:62)
at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:64)
at org.jboss.el.parser.AstPropertySuffix.getValue(AstPropertySuffix.java:53)
at org.jboss.el.parser.AstValue.getValue(AstValue.java:67)
at org.jboss.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
... 55 more
Caused by: java.lang.IllegalArgumentException: org.hibernate.hql.ast.QuerySyntaxException: unexpected token: ( near line 1, column 108 [SELECT DISTINCT count(csy.y20gpnum) as anzahl, csy.y20gpnum , csy.lat , csy.lon FROM csy20 AS csy JOIN ( SELECT w94.w94liefn, w94.w94erdav FROM csw94 as w94 JOIN ( SELECT w90.w90aufnr, w90.w90artgr, w90.w90kdauf FROM csw90 as w90 ) AS tab2 WHERE w94.w94aufnr = tab2.w90aufnr AND w94.w94artgr = tab2.w90artgr and tab2.w90kdauf like '00012%' ) AS tab WHERE csy.y20gpnum = tab.w94liefn AND tab.w94erdav >= '2005-12-01 20:43:00' and tab.w94erdav <= '2006-03-22 20:43:00' group by csy.y20gpnum order by anzahl]
at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:616)
at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:95)
at org.jboss.seam.persistence.EntityManagerProxy.createQuery(EntityManagerProxy.java:79)
at de..business.GmapBean.getResultList(GmapBean.java:219)
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:597)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
at org.jboss.seam.intercept.EJBInvocationContext.proceed(EJBInvocationContext.java:44)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:31)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:46)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.core.ConversationInterceptor.aroundInvoke(ConversationInterceptor.java:63)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:42)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:106)
at org.jboss.seam.intercept.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:53)
at sun.reflect.GeneratedMethodAccessor259.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:118)
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.invokeInCallerTx(TxPolicy.java:126)
... 97 more
Caused by: org.hibernate.hql.ast.QuerySyntaxException: unexpected token: ( near line 1, column 108 [SELECT DISTINCT count(csy.y20gpnum) as anzahl, csy.y20gpnum , csy.lat , csy.lon FROM csy20 AS csy JOIN ( SELECT w94.w94liefn, w94.w94erdav FROM csw94 as w94 JOIN ( SELECT w90.w90aufnr, w90.w90artgr, w90.w90kdauf FROM csw90 as w90 ) AS tab2 WHERE w94.w94aufnr = tab2.w90aufnr AND w94.w94artgr = tab2.w90artgr and tab2.w90kdauf like '00012%' ) AS tab WHERE csy.y20gpnum = tab.w94liefn AND tab.w94erdav >= '2005-12-01 20:43:00' and tab.w94erdav <= '2006-03-22 20:43:00' group by csy.y20gpnum order by anzahl]
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)
... 130 more
12:37:49,016 ERROR [PARSER] line 1:108: unexpected token: (
12:37:49,016 ERROR [PARSER] line 1:144: unexpected token: FROM
12:37:49,016 ERROR [PARSER] line 1:171: unexpected token: (
12:37:49,016 ERROR [PARSER] line 1:221: unexpected token: FROM
12:37:50,048 ERROR [PARSER] line 1:108: unexpected token: (
12:37:50,058 ERROR [PARSER] line 1:144: unexpected token: FROM
12:37:50,058 ERROR [PARSER] line 1:171: unexpected token: (
12:37:50,068 ERROR [PARSER] line 1:221: unexpected token: FROM
Name and version of the database you are using:MySQL-Client-Version: 5.0.41
The generated SQL (show_sql=true):Code:
[SELECT DISTINCT count(csy.y20gpnum) as anzahl, csy.y20gpnum , csy.lat , csy.lon FROM csy20 AS csy JOIN ( SELECT w94.w94liefn, w94.w94erdav FROM csw94 as w94 JOIN ( SELECT w90.w90aufnr, w90.w90artgr, w90.w90kdauf FROM csw90 as w90 ) AS tab2 WHERE w94.w94aufnr = tab2.w90aufnr AND w94.w94artgr = tab2.w90artgr and tab2.w90kdauf like '00012%' ) AS tab WHERE csy.y20gpnum = tab.w94liefn AND tab.w94erdav >= '2005-12-01 20:43:00' and tab.w94erdav <= '2006-03-22 20:43:00' group by csy.y20gpnum order by anzahl]
Das Problem scheint hinter dem ersten JOIN vor SELECT aufzutauchen.
Wäre wirklich sehr dankbar, wenn mir jemand weiterhelfen könnte!!
Gruß