Hibernate data retrieve improvement. [duplicate]
Possible Duplicate:
Can I eager lo开发者_运维技巧ad a property using HQL?
I will try to synthesize the issue by abstracting the real scenario.
I have EntityA which has EntityB as member and is lazily loaded.
EntityB has as well as member EntityC
What I do now is not very optimum
select distinct entA from EntityA entA ,EntityB entB, EntityC entC
where entA.ent_B_ID = entB.id and entB.ent_C_ID = entC.id and entC.someValue ='x'
This will retrieve all entityA objects but I have to call on each of these objects getEntityB and on entityB getEntityC to have the full object ,so too many DB calls for this lazy loading.
Mention:I can't override mappings.
Before (years ago) I used JDBC and there with sql I would have done something similar but with HQL can I retrieve full entityA objects in 1 query ?
Thank you!
You need to use in "fetch" or on the criteria or in the hql or you can set on the relation - lazy=false
精彩评论