-->
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: Help with HQL query :)
PostPosted: Thu Jun 07, 2007 5:13 pm 
Newbie

Joined: Tue Apr 17, 2007 7:57 pm
Posts: 6
Im looking for a way to do a sub-select like follows (I know this doesn't work but you get the idea):

Code:
String[] values = {"DOG","CAT","LIZARD"};

List results = session.createQuery("from Animals where species in(?)")
  .setParameter(0,values).list();


How do i get this sort of thing to work without having to convert my values array into a string? Is that the only way?

Thanks in advance


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 07, 2007 5:40 pm 
Newbie

Joined: Tue Apr 17, 2007 7:57 pm
Posts: 6
nm i figured it out. the following works:

Code:
List values = new ArrayList();
valuse.add("DOG");
values.add("CAT");
values.add("Lizard");

List results = session.createQuery(
  "from Animals where species in (:species)")
    .setParameterList("species", values).list();


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.