-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: HQL with multiple fetch joins
PostPosted: Wed Nov 09, 2011 7:53 am 
Newbie

Joined: Wed Nov 09, 2011 7:44 am
Posts: 7
Hi, I'm trying to read data with Hibernate 3.6.8.
I have this kind of query

SELECT
a
FROM
A as a left join fetch a.b as b
left join fetch a.c as c
WHERE
a.id = :id AND
b.name = :name AND
c.name = :name

There are 3 tables: A, B, C. "A" is the master table joined with "B" and "C" with a One-to-many relationship.

If I join just one table a time (example: a left join fetch b or a left join fetch c) everything works.
But with both tables it happens that the returned object A will contains data fetched from the table C but not the ones fetched from the table B.
If I close the transaction after the query it happens:
a.getB() -> error since it's not possible to lazily read data with a closed session.
a.getC() -> Works and returns just the element selected in the query.

Can anybody help me, please? What is wrong?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.