Hi,
I've got two classes like Car and Bike which both inherit from Vehicle and are stored using a single table strategy.
Now I would like to change the class of a persistent object without changing its id. Yes, I do have a need for that :-)
In plain database terms it would mean to modify the discriminator field's value for that row (and perhaps some fields representing the instance's properties).
But is there a way to do that in Hibernate?
I've tried to turn a bike into a car with some code like this:
//retrieve bike from database
...
id = bike.getId();
entityManager.clear();
car = new Car();
car.setId(id);
entityManager.merge(car);
But that just creates a new car without caring about the id I set.
Any ideas appreciated!
Norbert
|