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 retrieve data by criteria?
PostPosted: Tue Nov 02, 2004 3:32 am 
Beginner
Beginner

Joined: Fri Feb 27, 2004 3:49 am
Posts: 25
Hi, i need somebody help.

In my case, i have two objects(parent, child) and i want to retrieve parent.name and child.name by a search criteria.

parent model
----------------
String name
List childList

child model
--------------
String name


Critetria crit = sess.createCriteria(parent.class);
crit.add(Expression.eq("name","parentNameValue");
crit.add(Expression.eq("childList.name","childNameValue");

but i got a error mention that can't found 'childList.name' from parent.class. how to solve this problem?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 03, 2004 12:09 pm 
Beginner
Beginner

Joined: Fri Mar 26, 2004 8:19 am
Posts: 49
yeah, i just ran into this

create a sub criteria off of the first criteria


Critetria crit = sess.createCriteria(parent.class);
Critetria subCrit = crit.createCriteria("childList");

// expressions here

I believe what you can also do is call list() on both criterias and combine them together to form your final result


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.