pete
unread,Jun 25, 2012, 10:07:07 AM6/25/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to quer...@googlegroups.com
Hej,
I'm wondering: Does QueryDSL put the entities I query for into the hibernate context/cache so that they can be accessed from there? I'm thinking, if I run a join for an entity, explicitly collecting all child relations, I should be able to save on the lazy loadings. I just can't figure out how..
Example: A has Bs and B has Cs. Now if I build my query to fetchAll() for a certain A and also join it with Bs and Cs:
List<A> as = query.from(QA.a).leftJoin(QA.a.b,QB.b).leftJoin(QB.b.c,QC.c).where(a.id.eq("1)).fetchAll();
I will get a nice SQL statement that says
select... from A inner join B ... inner join C ... where ...
So the result should be sufficient for hibernate to initialize
as.get(0).getBs()
as.get(0).getBs().get(0).getCs()
but it won't do it, instead it will run querries to
select B where B.a = A.id...
Is it possible at all to reduce these lazy loadings by initializing an entity with all children with one join or am I hoping for too much?
Also: If I load all the data with a join, will hibernate have them in its cache and will it access that cache for those lazy loadings or will it poll the database? Do I get a say in that or is it completely out of my hands?
Thanks @ all!