-->
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: Trouble initiating auto delete on one-to-one mapped child
PostPosted: Sun Oct 01, 2006 11:17 pm 
Newbie

Joined: Thu Dec 08, 2005 12:19 pm
Posts: 6
I am trying to delete a property from my parent object which has a one-to-one relationship to the property, but unfortunately, hibernate doesn't let me set cascade="all-delete-orphan" for a one-to-one mapped property.

The save of a new property and update of an existing property is working great, however, the behaviour that I'm looking for and missing is that I want the propertydata row to be deleted from the database for a given user's property if the following were executed. Simply setting the ObjectProperty.value to null wouldn't suffice because the legacy database has a non-null constraint on that column that has to stay there for our other apps to work. Any suggestions to easily resolve this?

myUserEntity.setFirstNameProperty(null);
sess.update(myUserEntity);


<class name="UserEntity"
entity-name="User"
schema="myschema"
table="users">

<id name="id" type="java.lang.Integer">
<column name="objectid"/>
<generator class="assigned"/>
</id>

<one-to-one name="firstNameProperty" entity-name="ObjectProperty" cascade="all">
<formula>objectid</formula>
<formula>1</formula>
<formula>0</formula>
<formula>23</formula>
</one-to-one>
</class>

<class name="ObjectPropertyEntity"
entity-name="ObjectProperty"
schema="myschema"
table="propertydata">

<composite-id>
<key-property name="objectid" column="objectid" type="java.lang.Integer"/>
<key-property name="classid" column="classid" type="java.lang.Integer"/>
<key-property name="pageid" column="pageid" type="java.lang.Integer"/>
<key-property name="propertyid" column="propertyid" type="java.lang.Integer"/>
</composite-id>

<property name="value" column="value" type="java.lang.String" length="255"/>

</class>


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.