-->
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.  [ 2 posts ] 
Author Message
 Post subject: Multi column IN clause
PostPosted: Fri Mar 17, 2006 5:07 pm 
Newbie

Joined: Mon Mar 13, 2006 5:19 pm
Posts: 5
I am having trouble converting my SQL code into appropriate HQL code. Specifically the following SQL

Code:
SELECT * FROM myTable WHERE (col1, col2) IN ((1,1),(1,2),(1,3))


I have managed to get a single column IN clause to work properly by passing a List to a named parameter, but I cannot figure out how to format the HQL to accomplish this for multiple columns. Every time I try and pass in an array of arrays it doesn't put in the parens. I would like to avoid having to write the whole string out like the following:

Code:
from myTable myt where (myt.col1, myt.col2) in ((?,?),(?,?),(?,?))


If it makes any difference I am using the latest version of Hibernate with Spring and class files generated from the Hibernate Synchronizer Eclipse plugin. The DAOs are also backed by the HibernateTemplate from Spring.

Thanks in advance.


Top
 Profile  
 
 Post subject: Additional Info
PostPosted: Fri Mar 17, 2006 5:28 pm 
Newbie

Joined: Mon Mar 13, 2006 5:19 pm
Posts: 5
Just as an example, when I try and do lists of lists I usually get the following exception:

Quote:
Caused by: <AST>:0:0: unexpected AST node: {vector}
at org.hibernate.hql.antlr.SqlGeneratorBase.inList(SqlGeneratorBase.java:3016)
at org.hibernate.hql.antlr.SqlGeneratorBase.exoticComparisonExpression(SqlGeneratorBase.java:2831)
at org.hibernate.hql.antlr.SqlGeneratorBase.comparisonExpr(SqlGeneratorBase.java:1203)
at org.hibernate.hql.antlr.SqlGeneratorBase.booleanExpr(SqlGeneratorBase.java:851)
at org.hibernate.hql.antlr.SqlGeneratorBase.whereExpr(SqlGeneratorBase.java:724)
at org.hibernate.hql.antlr.SqlGeneratorBase.selectStatement(SqlGeneratorBase.java:184)
at org.hibernate.hql.antlr.SqlGeneratorBase.statement(SqlGeneratorBase.java:117)
at org.hibernate.hql.ast.QueryTranslatorImpl.generate(QueryTranslatorImpl.java:203)
... 29 more


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.