I have a case where I have a relational model which I want to load with data in an xml file using the new dom4j entity mode features in hibernate 3. Part of the system models Document and Author entities, a many-to-one relationship, ie an Author has many documents.
The xml file looks like
Code:
<document>
<title>the title</title>
<author>joe.bloggs@acme.com</author>
</document>
both document and author tables use db2 identity columns as primary, surrogate keys. Author email is a natural key in the table. Can I set up a mapping for the document entity that will...
map to the correct author entry if it already exists and if it doesn't create it. So you see I want to cascade upwards to what is normally seen as the parent. This might make no sense in which case I am probably not explaining it well enough. Any help would be appreciated.
It seems any solution centres around the many-to-one element or the join element in the hibernate mapping but I am unsure as to which one to use.