-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Error parsing a subselect of a subselect.
PostPosted: Wed May 17, 2006 9:50 am 
Newbie

Joined: Wed Oct 12, 2005 10:50 am
Posts: 4
Hi!

I've got a problem with subselect of subselect, hibernate seems to have problem to parse my hql. Strange cause the hibernate generate the same code doing the 'pagination' (findPaginated).

Anyone ever did something like that?

Thanks!

This is my hql:
SELECT cot.vlCotacaoIndFinanceiro
FROM com.mercurio.lms.configuracoes.model.CotacaoIndicadorFinanceiro cot join cot.indicadorFinanceiro idf
WHERE idf.nmIndicadorFinanceiro = ?
AND idf.pais.id = ?
AND cot = (select subcot from
(select cif
from com.mercurio.lms.configuracoes.model.CotacaoIndicadorFinanceiro cif
where cif.indicadorFinanceiro = idf and cif.dtCotacaoIndFinanceiro <= ? ) subcot
where rownum = 1)


Hibernate version:3.0.5

Name and version of the database you are using:Oracle 9i

Full stack trace of any exception that occurs:13:34:39,548 ERROR [PARSER] *** ERROR: line 6:2: unexpected token: (
13:34:39,548 ERROR [PARSER] *** ERROR: line 8:77: unexpected token: subcot
13:34:39,548 ERROR [PARSER] *** ERROR: line 9:2: unexpected token: where
13:34:39,564 INFO [STDOUT] org.springframework.orm.hibernate3.HibernateQueryException: unexpected token: ( near line 6, column 2 [SELECT cot.vlCotacaoIndFinanceiro
FROM com.mercurio.lms.configuracoes.model.CotacaoIndicadorFinanceiro cot join cot.indicadorFinanceiro idf
WHERE idf.nmIndicadorFinanceiro = ?
AND idf.pais.id = ?
AND cot = (select subcot from
(select cif
from com.mercurio.lms.configuracoes.model.CotacaoIndicadorFinanceiro cif
where cif.indicadorFinanceiro = idf and cif.dtCotacaoIndFinanceiro <= ? ) subcot
where rownum = 1) ]; nested exception is org.hibernate.hql.ast.QuerySyntaxError: unexpected token: ( near line 6, column 2 [SELECT cot.vlCotacaoIndFinanceiro
FROM com.mercurio.lms.configuracoes.model.CotacaoIndicadorFinanceiro cot join cot.indicadorFinanceiro idf
WHERE idf.nmIndicadorFinanceiro = ?
AND idf.pais.id = ?
AND cot = (select subcot from
(select cif
from com.mercurio.lms.configuracoes.model.CotacaoIndicadorFinanceiro cif
where cif.indicadorFinanceiro = idf and cif.dtCotacaoIndFinanceiro <= ? ) subcot
where rownum = 1) ]
13:34:39,564 INFO [STDOUT] org.hibernate.hql.ast.QuerySyntaxError: unexpected token: ( near line 6, column 2 [SELECT cot.vlCotacaoIndFinanceiro
FROM com.mercurio.lms.configuracoes.model.CotacaoIndicadorFinanceiro cot join cot.indicadorFinanceiro idf
WHERE idf.nmIndicadorFinanceiro = ?
AND idf.pais.id = ?
AND cot = (select subcot from
(select cif
from com.mercurio.lms.configuracoes.model.CotacaoIndicadorFinanceiro cif
where cif.indicadorFinanceiro = idf and cif.dtCotacaoIndFinanceiro <= ? ) subcot
where rownum = 1) ]
at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:63)
at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:215)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:127)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:83)
at org.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:427)
at org.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:884)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:834)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
at com.mercurio.adsm.core.model.hibernate.AdsmHibernateTemplate$22.doInHibernate(AdsmHibernateTemplate.java:915)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:315)
at com.mercurio.adsm.core.model.hibernate.AdsmHibernateTemplate.find(AdsmHibernateTemplate.java:906)
at com.mercurio.lms.configuracoes.model.dao.CotacaoIndicadorFinanceiroDAO.findVlCotacaoIndFinanceiro(CotacaoIndicadorFinanceiroDAO.java:56)
at com.mercurio.lms.configuracoes.model.service.CotacaoIndicadorFinanceiroService.findVlCotacaoIndFinanceiro(CotacaoIndicadorFinanceiroService.java:49)
at com.mercurio.lms.configuracoes.model.service.CotacaoIndicadorFinanceiroService$$FastClassByCGLIB$$97e14381.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:661)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:122)
at com.mercurio.adsm.core.security.guard.model.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:92)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:606)
at com.mercurio.lms.configuracoes.model.service.CotacaoIndicadorFinanceiroService$$EnhancerByCGLIB$$ae1e12f4.findVlCotacaoIndFinanceiro(<generated>)
at com.mercurio.lms.contasreceber.model.service.CalcularJurosDiarioService.calcularPercentualJuroDiario(CalcularJurosDiarioService.java:102)
at com.mercurio.lms.contasreceber.model.service.CalcularJurosDiarioService.calcularVlJuros(CalcularJurosDiarioService.java:140)
at com.mercurio.lms.contasreceber.model.service.CalcularJurosDiarioService.findCalcularJurosDiario(CalcularJurosDiarioService.java:74)
at com.mercurio.lms.contasreceber.model.service.CalcularJurosDiarioService$$FastClassByCGLIB$$cd7bc232.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:661)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:122)
at com.mercurio.adsm.core.security.guard.model.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:92)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:606)
at com.mercurio.lms.contasreceber.model.service.CalcularJurosDiarioService$$EnhancerByCGLIB$$177e1e47.findCalcularJurosDiario(<generated>)
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 com.mercurio.adsm.core.model.distribution.SpringServiceCallImpl.invokeService(SpringServiceCallImpl.java:324)
at com.mercurio.adsm.core.model.distribution.SpringServiceCallImpl.execute(SpringServiceCallImpl.java:115)
at com.mercurio.adsm.core.model.distribution.ejbcommand.EJBCommandEJB.secureCall(EJBCommandEJB.java:92)
at com.mercurio.adsm.core.model.distribution.ejbcommand.EJBCommandEJB.execute(EJBCommandEJB.java:139)
at sun.reflect.GeneratedMethodAccessor129.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.invocation.Invocation.performCall(Invocation.java:345)
at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:214)
at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:48)
at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:105)
at org.jboss.ejb.plugins.AbstractTxInterceptorBMT.invokeNext(AbstractTxInterceptorBMT.java:153)
at org.jboss.ejb.plugins.TxInterceptorBMT.invoke(TxInterceptorBMT.java:62)
at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:113)
at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:122)
at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:192)
at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:624)
at org.jboss.ejb.Container.invoke(Container.java:870)
at sun.reflect.GeneratedMethodAccessor68.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:144)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
at org.jboss.invocation.local.LocalInvoker$MBeanServerAction.invoke(LocalInvoker.java:155)
at org.jboss.invocation.local.LocalInvoker.invoke(LocalInvoker.java:104)
at org.jboss.invocation.InvokerInterceptor.invokeLocal(InvokerInterceptor.java:115)
at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:101)
at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:46)
at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:55)
at org.jboss.proxy.ejb.StatelessSessionInterceptor.invoke(StatelessSessionInterceptor.java:97)
at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:91)
at $Proxy35.execute(Unknown Source)
at com.mercurio.adsm.core.model.distribution.ServiceCallDelegate.secureCall(ServiceCallDelegate.java:39)
at com.mercurio.adsm.core.model.distribution.ServiceCallDelegate.execute(ServiceCallDelegate.java:66)
at com.mercurio.adsm.core.web.XMLBrokerServlet.doPost(XMLBrokerServlet.java:67)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at javax.serv
13:34:39,564 INFO [STDOUT] let.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:75)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:66)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:153)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:54)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:595)
Caused by: line 6:2: unexpected token: (
at org.hibernate.hql.antlr.HqlBaseParser.fromRange(HqlBaseParser.java:1178)
at org.hibernate.hql.antlr.HqlBaseParser.fromClause(HqlBaseParser.java:1023)
at org.hibernate.hql.antlr.HqlBaseParser.selectFrom(HqlBaseParser.java:745)
at org.hibernate.hql.antlr.HqlBaseParser.queryRule(HqlBaseParser.java:599)
at org.hibernate.hql.antlr.HqlBaseParser.union(HqlBaseParser.java:680)
at org.hibernate.hql.antlr.HqlBaseParser.subQuery(HqlBaseParser.java:3220)
at org.hibernate.hql.antlr.HqlBaseParser.primaryExpression(HqlBaseParser.java:3349)
at org.hibernate.hql.antlr.HqlBaseParser.atom(HqlBaseParser.java:2980)
at org.hibernate.hql.antlr.HqlBaseParser.unaryExpression(HqlBaseParser.java:2758)
at org.hibernate.hql.antlr.HqlBaseParser.multiplyExpression(HqlBaseParser.java:2640)
at org.hibernate.hql.antlr.HqlBaseParser.additiveExpression(HqlBaseParser.java:2365)
at org.hibernate.hql.antlr.HqlBaseParser.concatenation(HqlBaseParser.java:471)
at org.hibernate.hql.antlr.HqlBaseParser.relationalExpression(HqlBaseParser.java:2154)
at org.hibernate.hql.antlr.HqlBaseParser.equalityExpression(HqlBaseParser.java:2110)
at org.hibernate.hql.antlr.HqlBaseParser.negatedExpression(HqlBaseParser.java:1981)
at org.hibernate.hql.antlr.HqlBaseParser.logicalAndExpression(HqlBaseParser.java:1909)
at org.hibernate.hql.antlr.HqlBaseParser.logicalOrExpression(HqlBaseParser.java:1864)
at org.hibernate.hql.antlr.HqlBaseParser.expression(HqlBaseParser.java:1632)
at org.hibernate.hql.antlr.HqlBaseParser.logicalExpression(HqlBaseParser.java:1799)
at org.hibernate.hql.antlr.HqlBaseParser.whereClause(HqlBaseParser.java:370)
at org.hibernate.hql.antlr.HqlBaseParser.queryRule(HqlBaseParser.java:605)
at org.hibernate.hql.antlr.HqlBaseParser.selectStatement(HqlBaseParser.java:260)
at org.hibernate.hql.antlr.HqlBaseParser.statement(HqlBaseParser.java:150)
at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:209)
... 113 more


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 17, 2006 3:59 pm 
Regular
Regular

Joined: Wed Aug 25, 2004 6:23 am
Posts: 91
Sorry but Hibernate 3 doesn't support subselects in the from clause (even though it may generate SQL that uses them). Would this do what you want, or does it have to be the first row of the subselect (even though there is no order specified?)

Code:
SELECT cot.vlCotacaoIndFinanceiro
FROM com.mercurio.lms.configuracoes.model.CotacaoIndicadorFinanceiro cot join cot.indicadorFinanceiro idf
WHERE idf.nmIndicadorFinanceiro = ?
AND idf.pais.id = ?
AND cot in (select cif
from com.mercurio.lms.configuracoes.model.CotacaoIndicadorFinanceiro cif
where cif.indicadorFinanceiro = idf and cif.dtCotacaoIndFinanceiro <= ?)


Top
 Profile  
 
 Post subject: Thanks!
PostPosted: Thu May 18, 2006 10:52 am 
Newbie

Joined: Wed Oct 12, 2005 10:50 am
Posts: 4
Thanks for the information but I really need the order by... I'm gonna have to divide it in 2 querys... It's gonna be slower but I'm getting use to this hibernate.

One day it will be a great tool!

Thanks again for the info!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.