-->
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: session.load and SQL generated
PostPosted: Mon Jul 20, 2009 11:14 am 
Newbie

Joined: Mon Jul 20, 2009 10:58 am
Posts: 1
Hello All

I searched history for my question but could not find any answers.

I have User with OneToOne to Profile

My question is regarding session.delete(o) and the SQL generated. I am doing:

Code:
User user= (User)session.load(id);
session.delete(user);



I expect to see the following:

Code:
delete from profile where id=? and version=?
delete from user where id=? and version=?



however, the following is what I see:

Code:
SELECT ................... from User
delete from profile where id=? and version=?
delete from user where id=? and version=?



On the user side, I have

Code:
@OneToOne(cascade = CascadeType.ALL)
@PrimaryKeyJoinColumn



on the profile side, I have

Code:
@OneToOne
@PrimaryKeyJoinColumn


According to the documentation, load() return a proxy and does not hit the database until and only if its properties are accessed. Accordingly, I understand that a select is not necessary when deleting an object like I specified above. Is my understanding correct? If not, then whats wrong with what I am doing?

Thank you


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.