-->
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-orphan and null foreign key constraint help
PostPosted: Tue Jun 01, 2010 11:48 am 
Newbie

Joined: Tue Jan 18, 2005 11:13 pm
Posts: 19
I'm having problems with the delete-orphan option and a non-null constraint on a map property. The Map maps a string to another "child" entity. When I remove an item from the Map and save the parent entity, I get the following error:

Caused by: java.sql.SQLException: Attempt to insert null into a non-nullable column: column: NAME table: TASK_TAG in statement [update task_tag set task_id=null, name=null where task_id=?]

In this case, TASK_TAG is the table for the child entity.

My question here, is why is hibernate trying to set all columns to null? Shouldn't it just try to delete the orphaned child entry? I've set cascase="all, delete-orphan" on the <map/> element in the parent entity.

This is hibernate core 3.2.6.

Thank you for the help.

Scott


Top
 Profile  
 
 Post subject: Re: delete-orphan and null foreign key constraint help
PostPosted: Thu Jun 03, 2010 3:50 am 
Newbie

Joined: Tue Jan 18, 2005 11:13 pm
Posts: 19
I've tracked this down to the OneToManyPersister.generateDeleteString() method. It seems to generate a sql statement that sets all foreign keys to null rather than deleting the entry. Does anyone know why it works this way? Does anyone know the proper approach here? How do i work around this?

I've seen some other posts about this, but no solutions.

Thanks for the help.


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.