-->
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: inner join fetch causing unexpected deletes
PostPosted: Tue Nov 23, 2004 11:11 am 
Beginner
Beginner

Joined: Wed Oct 01, 2003 3:57 am
Posts: 33
Location: Alpharetta, Georgia
Hibernate version: 2.1.6

Mapping documents: Generated with xdoclet

Code between sessionFactory.openSession() and session.close():
<br/>Using Springframework's OpenSessionInViewInterceptor

Full stack trace of any exception that occurs:

Name and version of the database you are using: MySQL 4.0x

I have an owning object called QualificationReviewSession. It owns a collection of QualificationReviewSessionUsers -- which is just a many-to-many mapping table containing a foreign key to the QualficationReviewSession and a foreign key to an associated User.
I want to load those qualificationreviewsessions which are associated with a particular users.

list = getSession()
.createQuery(
"select new com.ccg.qualreview.support.QualificationReviewSessionInfo(qrs.id,qrs.sessionName,qrs.client.name,qrs.notes) "
+" from QualificationReviewSession qrs "
+" inner join qrs.qualificationReviewSessionUsers as users "
+" where users=:user"
+" order by qrs.client.name, qrs.sessionName asc"
)
.setEntity("user",user)
.list()
;


This works just fine. The problem comes when I use:
+" inner join fetch qrs.qualificationReviewSessionUsers as users "

For some reason Hibernate will load the correct list, and proceed to
delete from qualificationReviewSessionUsers where qualificationReviewSession = ?

(unfortunately I don't have a current show_sql output. Since I solved it by taking out the "fetch" ...)

What's going on with that? ( In know, it's a really smart question.) Since I don't really need the User to be instantiated in this query I don't really need the fetch ... it seems like a bug - it also seems that I don't really understand fetch. Comments?


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.