Hi,
I have a direct-to-XML table representation where I've got a one-to-many representation between two tables that share a lot of the same columns. I want the behaviour to be such that my object representation of the children inherit values from the parent tables ONLY IF the child value for the matching column is NULL. Currently, I am doing XML post-processing and populating the element fields manually by inspecting to see if they are empty first. But wondered if there is a way to do this with Hibernate.
Here is the mapping:
Code:
<class
entity-name="parent"
table="parent">
<id name="key1" type="int"/>
<set name="children" inverse="true">
<key column="key1" not-null="true"/>
<one-to-many entity-name="child" embed-xml="true"/>
</set>
...
</class>
<class
entity-name="child"
table="child">
<composite-id>
<key-property name="key1" type="int"/>
<key-property name="key2" type="int"/>
</composite-id>
...
</class>
I'm wondering if I could somehow make use of <subclass/> functionality ... I played with this before, but ran into some difficulties.
Suggestions are appreciated. :)