Hi,
I have two classes : Person and Student.
A Student is a Person, so I map this using a subclass in a "table-per-hierarchy" strategy (this means using a discriminator-value which identifiates the class).
In the class Student there is a constructor which allows a Person object parameter, so that you can create a Student from a Person (in fact the constructor does a copy of all properties between both objects).
Nevertheless, when I'm trying to create and saving a Student from an existing Person like this :
Code:
Student oStudent = new Student(oPerson);
session.SaveOrUpdate(oStudent);
it creates a new Student row in the database, owed to the fact that I'm not using identies in my classes, but letting hibernate generate them.
But that's not what I want ! I would like that it only updates the discriminator column, to change the object type !
Even if I write an identity property for my classes, I got an error saying that it was not able to save the Student object because there was another object with the same ID in the database (typically the Person object)).
Do you see what I mean ?
Any help would be appreciated...