-->
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.  [ 3 posts ] 
Author Message
 Post subject: Selecting large number of objects by Id
PostPosted: Wed Oct 25, 2006 3:33 am 
Beginner
Beginner

Joined: Tue Oct 05, 2004 5:15 am
Posts: 23
Hi,

I've got a lucene index which based on a search can yield me a large number of IDs. These IDs are for objects which I've persisted thru hibernate. (The search results are limited to a hundred rows or so).

I then want to bring these objects back in thru Hibernate.
The simple approach seems to be just having a large number of ids in a WHERE ID IN (x1, x2, x3, ....).

I was just wondering whether this is the best way to do this, or whether there is a simpler / better way to query thru hibernate directly over a large number of primary keys?

Many thanks,

Dave


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 25, 2006 3:47 am 
Beginner
Beginner

Joined: Tue Oct 05, 2004 5:15 am
Posts: 23
It looks like I can logically do this easily enough with Critiera:

Code:
Collection<Long> ids = ...;
Criteria.add(Restriction.in("column", ids));


Is there a practical limit on the number of values in the "in" clause here? (Im looking to support something like 100)


Top
 Profile  
 
 Post subject: Solved...
PostPosted: Wed Oct 25, 2006 4:21 am 
Beginner
Beginner

Joined: Tue Oct 05, 2004 5:15 am
Posts: 23
A quick unit test against HSQLDB shows that this works fine...


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