Dear tribe,
I'm trying to figure out how to create an instance of a subclass for an instance of a superclass that already exists.
Consider two subclasses, Human and Woman (a joined-subclass of Human). Now, suppose i have a human record with 1 as the primary key. I tried creating the subclass instance like:
Code:
// get the superclass instance first
Human human = sess.load(Human.class, humanId);
// now create the subclass instance
Woman woman = new Woman();
woman.setSomething(something);
// try to save the woman
sess.save(woman, human.getId());
but the final line results in
net.sf.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session
my problem is that i have to create this subclass instance while the superclass instance is already there. Is there a way to do that or should i try to look at alternative ways to map this?
Thanks for your time and help,
Manos