-->
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: @ManyToOne, "on delete set null" - possible ?
PostPosted: Tue Oct 20, 2009 2:36 pm 
Newbie

Joined: Thu Oct 08, 2009 5:02 am
Posts: 2
Hello all,
Simple scenario:

I have a Person class, where each person has a House.
A house itself is oblivious to persons, it's a uni-directional relationship.

Code:
@Entity
public class Person {
   
   private House house;

   @ManyToOne
   public House getHouse() { return this.house; }
   public void setHouse(House house) { this.house = house; }
}


Now, what I want is to be able to delete a House without worrying about whether some person points to it or not.
If a Person happens to point to this House, I'd like his house field to be set to NULL.

I went through all different sorts of forums and jiras, and can't seem to find out -
Is this supported? How is this done (javax.persistence \ Hibernate) ?

Should I manually go and set the house field of Persons pointing to this House to null??

Thanks !


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.