-->
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: Is it possible to load a collection of objects?
PostPosted: Wed Nov 29, 2006 7:24 pm 
Newbie

Joined: Wed Nov 29, 2006 6:53 pm
Posts: 7
Hibernate version:3.1

I'm currently using the following code to load a single DataModification object based on its id:

Code:
public DataModification loadById(Integer modificationId) throws DataAccessException {
        return (DataModification) getHibernateTemplate().load(DataModification.class, modificationId);
}


If I have a collection of Ids I loop through it and call the method above for each Id that I have. Is there a way to send a collection of Ids to Hibernate and have a collection of objects returned? Or do I have to keep making multiple calls?

Thanks for your help!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 29, 2006 10:21 pm 
Newbie

Joined: Mon Jun 19, 2006 2:34 pm
Posts: 8
How about this:

Code:
query = session.createQuery("from DataModification where dateModificationId in (:dateModificationIds)");
            query.setParameterList("dateModificationIds", ids);
            return query.list();


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 30, 2006 4:16 pm 
Newbie

Joined: Wed Nov 29, 2006 6:53 pm
Posts: 7
Thanks for the response, your solution worked perfectly.


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.