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?