-->
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: Problems with HQL (many-to-many)
PostPosted: Mon Dec 12, 2005 11:32 am 
Newbie

Joined: Wed Dec 07, 2005 4:32 pm
Posts: 5
Hi people.
I'm executing this code:

AuthChaveAcesso chaveAcesso = (AuthChaveAcesso) session.load(AuthChaveAcesso.class, "100008");
Query query = session.createQuery("from Pedido p where p.agente.chavesAcesso in (:chaves) ");
query.setParameterList("chaves", new Object[] {chaveAcesso});
System.out.println(query.list());

And this error occurs: ERROR util.JDBCExceptionReporter logExceptions - ORA-00936: missing expression

This query is resulted:
select pedido0_.REPE_PEDIDO_NU as REPE1_, pedido0_.REPE_INCLUSAO_DT as REPE3_39_, pedido0_.REPE_OBSERVACAO_DS as REPE4_39_, pedido0_.REPE_OBSERVACAO as REPE5_39_, pedido0_.REPE_ENTREGA_FUNC_RG as REPE6_39_, pedido0_.REPE_ENTREGA_FUNC_NO as REPE7_39_, pedido0_.REPE_ENTREGA_FUNC_MT as REPE8_39_, pedido0_.REPE_ULT_ENVIO_CREDITO as REPE9_39_, pedido0_.REPE_PRIORIDADE as REPE10_39_, pedido0_.REPE_OBS_CABS as REPE11_39_, pedido0_.REPE_OBS_SCI as REPE12_39_, pedido0_.REPE_OBS_FUN as REPE13_39_, pedido0_.REPE_IMPR_ANALISE_DT as REPE14_39_, pedido0_.REPE_IMPR_SMP_DT as REPE15_39_, pedido0_.REPE_OBS_EQUIFAX as REPE16_39_, pedido0_.REPE_PARECER_EQUIFAX as REPE17_39_, pedido0_.REPE_CPF_AGENTE as REPE18_39_, pedido0_.REPE_NOTAS_RODAPE as REPE19_39_, pedido0_.CLPE_CLIENTE_CD as CLPE20_39_, pedido0_.USUA_ID as USUA21_39_, pedido0_.POVE_AGENTE_CD as POVE22_39_, pedido0_.STPE_STATUS_CD as STPE23_39_, pedido0_.TTRM_TRAMITE_CD as TTRM24_39_, pedido0_.TAMO_MOTIVO_CD as TAMO25_39_, pedido0_.REPE_CONTA_MESTRE_NU as REPE26_39_, pedido0_.REPE_CONTRATO_COMO_NU as REPE27_39_, pedido0_.TIPL_PLANO_CD as TIPL28_39_, pedido0_.PACM_PACOTE_CD as PACM29_39_, pedido0_.PRCO_PRAZO_CD as PRCO30_39_, pedido0_.PRPA_PRAZO_CD as PRPA31_39_, pedido0_.VEPE_VENCIMENTO_CD as VEPE32_39_, pedido0_.TRPE_TRANSPORTADORA_NU as TRPE33_39_, pedido0_.TIPP_TIPO_PEDIDO_CD as TIPP2_ from REPE_RELACAO_PEDIDO pedido0_, GA_VW_CADASTRO agente1_, CHGA_CHAC_GAVW chavesaces2_, CHAC_CHAVE_ACESSO authchavea3_ where agente1_.COD_CREDENC=chavesaces2_.COD_CREDENC and chavesaces2_.CHAC_LOGIN=authchavea3_.CHAC_LOGIN and pedido0_.POVE_AGENTE_CD=agente1_.COD_CREDENC and (. in (?))

This expression is corretly???
(. in (?))

The mapping is:

Agente.hbm.xml
<bag name="chavesAcesso" table="CHGA_CHAC_GAVW" inverse="true" lazy="true">
<key column="COD_CREDENC"/>
<many-to-many class="AuthChaveAcesso" column="CHAC_LOGIN"/>
</bag>

AuthChaveAcesso.hbm.xml
<bag
name="agentes"
table="CHGA_CHAC_GAVW"
lazy="true"
cascade="save-update,merge"
>
<key column="CHAC_LOGIN"/>
<many-to-many class="Agente" column="COD_CREDENC"/>
</bag>

Thanks in advance

Hibernate version: 3.0.5

Mapping documents: all entities

Code between sessionFactory.openSession() and session.close():
via Spring Framework

Full stack trace of any exception that occurs:

07/12/05 18:12:06 ERROR util.JDBCExceptionReporter logExceptions - ORA-00936: missing expression

org.hibernate.exception.SQLGrammarException: could not execute query
at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:70)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.doList(Loader.java:1596)
at org.hibernate.loader.Loader.list(Loader.java:1577)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:395)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:271)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:844)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
at vivo.hibernate.Tester.functionPedido(Tester.java:94)
at vivo.hibernate.Tester.main(Tester.java:78)
Caused by: java.sql.SQLException: ORA-00936: missing expression


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

Debug level Hibernate log excerpt:
info


Top
 Profile  
 
 Post subject: try this
PostPosted: Mon Dec 12, 2005 7:00 pm 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
Try rewritig query as:
Query query = session.createQuery("from Pedido p where p.agente.chavesAcesso in ( from AuthChaveAcesso aca where aca.id = :id ) ");
query.setParameter("id", "100008");

_________________
--------------
Konstantin

SourceLabs - dependable OpenSource systems


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 09, 2006 12:41 pm 
Newbie

Joined: Wed Dec 07, 2005 4:32 pm
Posts: 5
Hi, kgignatyev.
Don't work with your code.
Thanks a lot.


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.