| Author |
Hibernate eager fetching issue
|
RamandeepS Singh
Ranch Hand
Joined: Aug 25, 2009
Posts: 59
|
|
Hi
I am newbie to hibernate
i have a self refrencing class user having one to many relation
i am using association table for one to many
i have 4 users having following records
1 abc
2 def
3 ghi
4 jkl
following records are there in association table
user child
1 2
1 3
1 4
when i am using lazy fetching and using criteria query to fetch user 1
its giving me 1 record and when i get childs its giving me 3 records that is working fine
BUT when i change it to eager
It is giving me thrice record 1
Thanks
Ramandeep Singh
|
 |
Samdani masum
Greenhorn
Joined: Oct 10, 2010
Posts: 3
|
|
|
please give me complete model class then I shall give a solution for Eager fetching related data from orm .
|
 |
Ibrahim Aziz
Greenhorn
Joined: Oct 17, 2011
Posts: 8
|
|
The following should solve your problem:
Session ss = hibernateUtil.getSession();
Criteria crit = ss.createCriteria(Whatever.Class);
crit.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
|
 |
 |
|
|
subject: Hibernate eager fetching issue
|
|
|