Hi,
I am having difficulty performing updates on some persisted objects. In my situation, I have an abstract class(call it "Animal") which is extended by three concrete classes(call them "Cat", "Dog", and "Horse"). Niether Cat, Dog, nor Horse contain any fields of their own; the only thing that differs between them and Animal is the functionality of their methods. The hbm file for Animal looks something like this:
Code:
<hibernate-mapping>
<class name="Animal" table="animals">
<id name="id" type=...
<subclass name="Cat"
lazy="true"
discriminator-value="Cat">
</subclass>
<subclass name="Dog"... </subclass>
<subclass name="Horse"... </subclass>
</class>
</hibernate-mapping>
I would like to be able to load a Cat object, modify some of its fields, and then update it such that it gets persisted as a Dog object(ie, change the discriminator value). When I load the Cat object; copy all of its fields into a new dog object; modify some of those fields; and then update the database with this Dog object, the fields get correctly modified but the object is still stored as a Cat. In other words, Hibernate has refused to touch the discriminator-value of an object upon updating it.
So my question is: is it possible to modify a persisted object's class type and then update it, and have this change be reflected in the discriminator column?
Thank you,
Chris