stolley wrote:
Or model the whole shebang as a composite pattern:
http://forum.hibernate.org/viewtopic.php?t=926542
Thanks for the suggestion, but I'm not sure this scenario really fits the Composite Pattern: i.e. I don't have any object composition in a tree structure and/or need to represent this relationship as a part/whole hierarchy.
Unless I am misunderstanding the intent of the pattern?
What I am really looking for is an approach to casting instances down the class hierachy tree and updating the persisted instances accordingly:
- at some point I have a Person instance
- at a later time, I gain further information about this Person which allows me to classify them as a Parent or a Child (which are both subclasses of Person)
The only approach to this with Hibernate I have found so far is to delete the Person, instance a Parent or Child instance, and then save again in this new state.
This seems like a very clumsy approach, and I am sure there must be a better way of doing this.
Another approach would be to rework my class relationships so that this 'type' of person is an attribute of a Person, instead of a subclass, but this does not seem a very pure OO approach.
Thanks,
Kevin Hooke