I have tried reading the documentation and also the posts on the user forum but i havent read an issue similar to mine.
To put it simply all I want to know is that does something similar to "delete-orphan" construct of "one-to-many" relationships exists for a single reference (mapped by many-to-one).
I cannot map the properties as one-to-one since I need to have their own idfentifier, and secondly for FK not found i am ok with catching an exception or ignoring it. But for certain containment relationships I would want to delete the orphaned object from teh database. So for collections I saw a construct from Hibernate but I couldnt find any solution for a non-collection property.
for example object EmailAccount has a non-collection, contained reference to object AddressBook.
Now a user can manipulate EmailAccount's addressBook property and either make it null or point to a different Addressbook object. Now when such a thing happen it implies that the original value for the addressBook property is orphaned and hence I would want it to get deleted from the database. Just as removing an object from the collection makes it orphaned and it is automatically deleted by Hibernate from the DB.
Hibernate version:
3.0.5
Mapping Excerpt:
<joined-subclass name="EmailAccountImpl" table="TEmailAccount1072563749" batch-size="10">
<key column="PK_persistentIdentifier"/>
<many-to-one not-found="exception" name="addressBook" class="AddressBookImpl" column="FK_addressBook3_AddressBook0" not-null="true" cascade="save-update" lazy="proxy" fetch="select" access="com.informatica.persistence.ormappinggenerator.SinglePropertyAccessor"/>
</joined-subclass>
I would really appreciate any help on this.
Thanks in Advance!!!!!!!
One of teh issues on Jira had something to with delete-orphan wrt to many-to-one relationships.
http://opensource.atlassian.com/project ... wse/HBX-81
Which read:
'To solve this issue I made a new annotation "org.hibernate.annotations.OrphanDelete", later in the binding process when OneToMany or ManyToOne is found I check for the existence of OrphanDelete annotation and then pass the info to the method "AnnotationBinder.getCascadeStrategy" '
This gave me hope that dlete-orphan could be used for mnay-to-one relationships in non-ejb persistence too. I tried using it and I did not get any mapping failures but the orphaned object did not get deleted.