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