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?
|