-->
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.  [ 4 posts ] 
Author Message
 Post subject: How to write query using IN expression with parameter value?
PostPosted: Thu Feb 07, 2008 1:15 pm 
Newbie

Joined: Fri Mar 02, 2007 4:32 pm
Posts: 6
Here is the from clause from Hibernate documentation:
from DomesticCat cat where cat.name in ( 'Foo', 'Bar', 'Baz' )

I am trying to pass parameter (String array) instead of literals: 'Foo', 'Bar', 'Baz', like this: new String[]{"transfer1", "transfer2"}


My query looks like this:
select transfer from TransferImpl as transfer
where transfer.name in (?)

I am getting empty collection in return.
Where is the problem? Is query OK?

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 07, 2008 1:43 pm 
Newbie

Joined: Mon Aug 15, 2005 3:43 am
Posts: 15
Have you tried a list instead of array?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 11, 2008 11:10 am 
Newbie

Joined: Fri Mar 02, 2007 4:32 pm
Posts: 6
arashbi wrote:
Have you tried a list instead of array?

I did. Still no solution. Thank you.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 11, 2008 10:04 pm 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
DanKe wrote:
I did. Still no solution. Thank you.



Do you use Query.setParameterList(String name, Object[] vals)? What is your actual query if you use a jdbc logger such as p6spy?



Farzad-


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