-->
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: how to use 'in' in hibernate?
PostPosted: Thu Nov 13, 2008 5:32 pm 
Newbie

Joined: Mon Dec 10, 2007 8:50 pm
Posts: 7
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:

Mapping documents:

select
e.elem_id
from
src.com.Elements as e
where
e.name in(?)


how to use 'in' in hibernate?

I tried sending parms as a Sting

String a = "'aa','bb','cc'";

also tried with String[]
String[] new String[]{"aa","bb","cc"};

both dint seem to work.

Can any one tell me how can i send parameters for (?) in the query.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 13, 2008 8:20 pm 
Newbie

Joined: Thu Nov 13, 2008 3:25 pm
Posts: 5
Use named parameter in your query:

select
e.elem_id
from
src.com.Elements as e
where
e.name in(:listName)


List list = new ArrayList();
list.add("aa");
list.add("bb");
query.setParameterList("listName", list);



Also unless you sure that list contains at least one element you have to check that it is not empty or you will get an error.


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.