-->
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 findbycriteria objects equals to the list of objectID
PostPosted: Fri May 08, 2009 7:40 am 
Newbie

Joined: Fri Mar 27, 2009 7:09 am
Posts: 3
Hi,
I have classes like this:
Code:
History{
Integer _id;
String _name;
MyObject _myObject;
}

MyObject{
Integer _id;
String _name;
}


And I have list:
Code:
List<MyObject> myObjects

I want to say that this list is not a list of full MyObjects... the Myobject have only _id, they dont have _name value;

I want to find all Histories which include myObject from the list. My idea was:

Code:
DetachedCriteria criteria = DetachedCriteria.forClass(History.class);
int i=0;
for (MyObject myObject: myObjects) {
       criteria.createCriteria("myObject",i).add(Property.forName("id").eq(equipment.getId()));
       i++;
}
return getHibernateTemplate().findByCriteria(criteria);


But Its not suprise for me that it doesnt work. Can anybody help me with this issue??


Top
 Profile  
 
 Post subject: Re: how to findbycriteria objects equals to the list of objectID
PostPosted: Fri May 08, 2009 8:39 am 
Beginner
Beginner

Joined: Wed Oct 03, 2007 4:10 am
Posts: 46
DetachedCriteria criteria = DetachedCriteria.forClass(History.class);
c.add(Restrictions.in("_myObject.id", new Integer[]{....your ids...});
getHibernateTemplate().findByCriteria(criteria)

_________________
Alexandru BARBAT


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.