-->
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.  [ 2 posts ] 
Author Message
 Post subject: left join fetch migration question
PostPosted: Sun Jul 07, 2013 11:02 am 
Newbie

Joined: Tue Nov 02, 2004 5:37 pm
Posts: 17
Hi there,

i am currently migrating from hibernate 3 to 4. I managed to sort out the dependencies but i am facing the popular : "org.hibernate.QueryException: query specified join fetching, but the owner of the fetched association was not present in the select list..." issue . I used to do the below in order to force hibernate to fetch the entire object and it's collection properties i.e. an Employee with many Departments and the address of each department.

So in hsql i had something like :

select e from Employee as e left join fetch e.department left join fetch e.department.address where e.id= ....

This worked fine but in new hibernate i can only fetch the properties that belong directly to the employee object and not the department. So what i would like is to get all properties because the session is closed after the query and lazy obviously raises an exception.

I would really appreciate your help in sorting this out.

Kind Regards


Top
 Profile  
 
 Post subject: Re: left join fetch migration question
PostPosted: Mon Jul 08, 2013 5:58 am 
Newbie

Joined: Tue Nov 02, 2004 5:37 pm
Posts: 17
i figured out what was needed and i am posting here for others having the same issue.

the query should be :

"select e from Employee as e left join fetch e.department as department left join fetch department.address where e.id="

So we have to use an alias "department"


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

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.