-->
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 do select .. where .. in (.. , .. , ..)
PostPosted: Mon Mar 26, 2007 10:46 am 
Newbie

Joined: Mon Mar 05, 2007 4:38 am
Posts: 17
Hi all,
I am using a named query to get a list of Tickets which works fine.
However, I'd like to extend the funcions and wonder how I could make a query like SELECT * FROM Ticket WHERE status IN ( one , two, three)

Obviously I don't know how many params I have in the IN clause. Previously (with only one status) I called my query like:

Code:
    tickets = session.getNamedQuery("ticketList")
      .setString(0, user.getName())
      .setString(1, user.getCompany())
      .setString(2, status)
      .setInteger(3, product.getId())
      .list();


Could anyone explain how to realise this IN clause ?
Thanks

Hibernate version: 3.2.2 GA


Top
 Profile  
 
 Post subject: setParameterList
PostPosted: Mon Mar 26, 2007 10:51 am 
Regular
Regular

Joined: Wed Aug 24, 2005 11:49 am
Posts: 63
hql: .... where status in (:statusList)

Code:
list = new ArrayList();
list.add("one");
list.add('two");

query.setParameterList("statusList", list);

_________________
Edwin van der Elst
Finalist IT Group


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.