wk5657 wrote:
In a regular class heirarchy, I would create an instance of the subclass and copy in the supoerclass properties. Unfortunately, in a Hibernate heirarchy, you cannot create the subclass instance with the same identity without deleting the original (database primary key constraints).
When creating a new instance of the subclass, you would create a Java object that has nothing to do with the original object. References to the original object would not be changed to the new one, and you wouldn't have a way in Java even to find all those possible references. In short: Changing the subtype of an object isn't supported in Java, and there is no way around this.
Getting a new id created for the new object therefore just mirrors the Java object identity situation. Foreign keys pointing to the old row won't change automatically to the new one. However, you even have the possibility to retrieve all objects that point to the old one from the database, and to re-associate them to the new one.