-->
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: HQL: Binding parameter to a collection expression
PostPosted: Thu Sep 01, 2005 9:48 am 
Newbie

Joined: Mon Feb 23, 2004 8:30 am
Posts: 13
Location: Istanbul, Turkey
Hi,

I want to bind a collection object to a positional parameter in an HQL statement as:

from SomutKart k where k.barkodNo in elements(?)

I want to bind a collection object to the positional parameter. But the code throws and SQLException. Is this not a legal HQL action?

Hibernate version:2

Mapping documents:

Code between sessionFactory.openSession() and session.close():
getHibernateTemplate().find("from SomutKart k where k.barkodNo in elements(?) order by k.adres1, k.adres2, k.adres3, k.barkodNo", kartlarinBarkodlari);

this is Spring equivalent to session.find(...)


Full stack trace of any exception that occurs:
org.springframework.jdbc.BadSqlGrammarException: Bad SQL grammar [] in task 'Hibernate operation'; nested exception is java.sql.SQLException: ORA-00907: missing right parenthesis

java.sql.SQLException: ORA-00907: missing right parenthesis

at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:189)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:242)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:554)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1478)
at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteDescribe(TTC7Protocol.java:677)
at oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.java:2371)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2660)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:457)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:387)
at net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:87)
at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:795)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:189)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.doList(Loader.java:950)
at net.sf.hibernate.loader.Loader.list(Loader.java:941)
at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:834)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1512)
at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39)
at org.springframework.orm.hibernate.HibernateTemplate$24.doInHibernate(HibernateTemplate.java:521)
at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:243)
at org.springframework.orm.hibernate.HibernateTemplate.executeFind(HibernateTemplate.java:263)
at org.springframework.orm.hibernate.HibernateTemplate.find(HibernateTemplate.java:512)
at org.springframework.orm.hibernate.HibernateTemplate.find(HibernateTemplate.java:507)
at mil.tsk.kybs.servis.dao.HibernateKartDao.findKartByBarkodNo(HibernateKartDao.java:168)


Name and version of the database you are using:

The generated SQL (show_sql=true) (abridged):
select somutkart0_.KART_N_REFNO as KART_N_R1_, somutkart0_.KART_V_BARKOD as KART_V_B6_, somutkart0_.KART_N_KART_AILESI_REFNO as KART_N_26_ from KART_TAB somutkart0_ where (somutkart0_.KART_V_BARKOD in ?.elements ) order by somutkart0_.KKISI_V_ADRES1 ,


Debug level Hibernate log excerpt:DEBUG

Thanks,

Mert Nuhoglu
http://jroller.com/page/mnuhoglu/

_________________
Mert Nuhoglu
http://jroller.com/page/mnuhoglu


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 01, 2005 11:11 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Code:
session.createQuery( "from SomutKart k where k.barkodNo in (:valueList)" )
        .setParameterList( "valueList", yourListOfValues )
        .list();

No idea what the equivalent would be in spring.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 02, 2005 1:15 pm 
Newbie

Joined: Mon Feb 23, 2004 8:30 am
Posts: 13
Location: Istanbul, Turkey
Thanks Steve...

_________________
Mert Nuhoglu
http://jroller.com/page/mnuhoglu


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.