Hi,
I am thinking of technique similar to this
http://opensource.atlassian.com/projects/hibernate/browse/HHH-552 but applied to collections. I would like to define a association in hbm but I don't need it at the POJO level. The only purpose of this association (collection) is to define cascade="delete" which will delete all associated objects when its parent is deleted.
There is no
update="false" attribute available on collection. I can try to define
inverse="true" on the collection together with noop accessor but i am not sure if this is valid solution or rather kind of hack. If one could give me some hint I would be grateful.
This is the view of the situation:
Code:
<class name="Parent">
<!--
I would like to make this association "dummy" - non existing at the pojo level, but performing delete cascade when parent is deleted
-->
<set name="children" access="org.hibernate.property.NoopAccessor" cascade="delete">
<key column="FKparent" />
<one-to-many class="Child" />
</set>
</class>
<class name="Child">
<!-- this end is actualy used by application -->
<many-to-one name="parent" class="Parent" column="FKparent" not-null="true" />
</class>