Hi all,
I’m considering how to best use my data model to insert an object graph into an empty database. A couple of issues that I want to cover:
- My data model has heavy inheritance with a combination of joined and mapped subclasses. Because Hibernate is the final arbiter of storage in this case, I'd like to be able to throw objects at Hibernate and let it work out diffusing of the data into the respective tables. In this manner, if I change the inheritance layout, the same objects will automatically save in the then-current layout.
- Because this agile layout will have different tables, it will likely generate different keys, breaking hardcoded loads.
In the past, I’ve used XStream to serialize XML that should make up the initial data, then iterate over the deserialized list that it gave me back at load time, saving those objects with Hibernate using cascade for associations. I could imagine LB having a loadObject element that accepted the same XML (as CDATA) as a part of the changelog. But I took a look at this and gave up after a few hours of banging on it, getting Hibernate working under LB didn’t seem very clean at all.
Am I overthinking the problem? What’s the best way to store an object with a complex (and possibly fluid during development) mapping structure like this?
Thanks, Brian