开发者

Hibernate data retrieve improvement. [duplicate]

开发者 https://www.devze.com 2023-03-21 02:15 出处:网络
This question already has an answer here: Closed 10 years ago. Possible Duplicate: Can I eager lo开发者_运维技巧ad a property using HQL?
This question already has an answer here: Closed 10 years ago.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消