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: Delete problem for one-to-one relationship
PostPosted: Tue Apr 10, 2007 6:14 am 
Newbie

Joined: Tue Mar 13, 2007 10:36 am
Posts: 5
Hi,

I have two POJOs: Login and Alias. They have one-to-one association between them.

So Login has field:
Code:
  Alias alias


and Alias has field:
Code:
  Login login.



Now let's assume that we are updating the Login record. When Alias field is blank in the UI, I want to delete the corresponding Alias from the database.

I am calling
Code:
  login.setAlias(null);


But it does not delete the record from the database.

I am using the following mapping in Login.hbm.xml

Code:
<one-to-one name="alias" class="com.sungard.cs.admin.login.Alias" property-ref="login" cascade="save-update" />


Any help! Thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 10, 2007 9:09 am 
Expert
Expert

Joined: Tue Jul 11, 2006 10:21 am
Posts: 457
Location: Columbus, Ohio
If you were deleting the Login, you could change your mapping for Login to cascade="save-update,delete". If you are not deleting the Login, then why not session.delete(login.getAlias()) instead of setting the Alias to null?


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.