-->
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: Why get dupicate parent instances in Criteria query?
PostPosted: Sun Feb 29, 2004 11:53 pm 
Regular
Regular

Joined: Wed Dec 03, 2003 9:41 pm
Posts: 87
In parent-child association, I found hibernate will select dupicate parent data if there is more than one child data.
e.g.
Code:
parent table schema:
id, name
child table schema:
id, parent_id, child_name


Code:
parent data:
1, parent1
child data:
1, 1, child1
1, 2, child2


I use Criteria to query data.
Code:
      Criteria crit = session.createCriteria(DePurchaseOrderModel.class);
      crit.add(Example.create(searchModel).enableLike(MatchMode.EXACT));
      crit.list();

The result are two parent instances. Both include a set of two same children(child1, child2). And the two instance are same ("==" reture true). But I really want to get one instance with a set of two children. What should I do?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 01, 2004 4:00 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Handle it yourself in your java code.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 01, 2004 5:21 am 
Regular
Regular

Joined: Wed Dec 03, 2003 9:41 pm
Posts: 87
OK. I did it. But I really want hibernate deal with it automatic. Can you please tell me why hibernate not do it?


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.