-->
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.  [ 4 posts ] 
Author Message
 Post subject: On delete set null...
PostPosted: Mon Feb 02, 2009 11:33 am 
Newbie

Joined: Wed Oct 11, 2006 4:54 am
Posts: 5
Hi,

I have a question which I can't find the answer to.

I have two tables. A and B
A is the parent and can have a B.
B is not aware of which A has it.

I have set up so that everything works the way I want except for one thing. I want to be able to delete a B and when I do that, the reference in A should be set to null.

In other words:
a (a1) has a b (b1)
I delete b1
a1 has no b1, the field b is set to null for a1.

It's very easy to do this in MySQL Query browser. Just set the foreign key in table A to (on delete set null).

But is there a way that hibernate can generate the schema automatically?
I'm using the following xml for the reference in table A.
Code:
<many-to-one name="b" column="b_id" class="B" cascade="none" fetch="join" not-null="false" lazy="false"/>


And this generates a foreign key reference in table A, which I want to include a "ON DELETE SET NULL".

Hope that my example describes what I want to do.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 06, 2009 5:40 am 
Newbie

Joined: Wed Oct 11, 2006 4:54 am
Posts: 5
so hibernate does not support this?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 06, 2009 7:44 am 
Regular
Regular

Joined: Fri Jan 30, 2009 10:10 am
Posts: 74
Location: London
From your description it sounds as though the A object has an ownership relationship with the B object, so it might make sense to have all access to the B object go via it's owner. Then you could move the deletion/removal responsibility into object A.

This is based on the assumption that objects of type B cannot exist without belonging to an object of type A.


--
Stephen Souness


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 06, 2009 9:29 am 
Expert
Expert

Joined: Fri Jan 30, 2009 1:47 am
Posts: 292
Location: Bangalore, India
Nope this is not supported. See this feature:
http://opensource.atlassian.com/project ... e/HHH-2707

Please vote for it so that it gets implemented.

_________________
Regards,
Litty Preeth


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.