File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes set null on delete of one to one relationship Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Object Relational Mapping
Reply Bookmark "set null on delete of one to one relationship" Watch "set null on delete of one to one relationship" New topic
Author

set null on delete of one to one relationship

Sharon Adar
Greenhorn

Joined: Apr 29, 2007
Posts: 18
hibernate 3.2.1 w\ MySql

I�m having problem with the way hibernate manages one-to-one relationship.
Before starting, some history regarding the problem:

http://opensource.atlassian.com/projects/hibernate/browse/HHH-2707\
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2007

As far as I�m concern, when creating a new one to one relationship between �myTable� and �My otherTable�, the creation SQL will define the constraints �on delete� default to �restrict�

SQL creation command example:

That causes be a lot of troubles when trying to remove myOtherTable instance.

A lot of problems example:

A good solution here will be to change the constraint �on delete� default to �set null�, yet, I didn�t find a way to make hibernate to do this for me. The only options as I can see that are
a) To manage the delete by my own .
b) To create my DB alone.

Any better solutions?

G�day!
 
 
subject: set null on delete of one to one relationship
 
Threads others viewed
JPA and static inner class, possible?
Hibernate and CGLIB
Hibernate I18N Repeated column with composite IDs
Hibernate tool code generation org.hibernate.MappingException: Foreign key
LockMode.UPGRADE produces false sql ?
MyEclipse, The Clear Choice