H
Harry
Dear,
I have three entities, having a class hierarchy like this:
Person
/ \
Teacher Student
I have implemented these three entities using "Separate Table per
Subclass" approach (ie. strategy=InheritanceType.JOINED), and all
works well including inserting, updating and removing.
Now, I have made an entity instance for Teacher, and I want to change
it from Teacher to Student. Given that I guess the PK cannot be
changed, as it's the key for joining other tables. How should I do
that?
1. should I directly update using merge(), or
2. should I put the information to a new Student object, and use
persist(), or
3. should I remove the instance from Teacher first
Thanks,
Harry
I have three entities, having a class hierarchy like this:
Person
/ \
Teacher Student
I have implemented these three entities using "Separate Table per
Subclass" approach (ie. strategy=InheritanceType.JOINED), and all
works well including inserting, updating and removing.
Now, I have made an entity instance for Teacher, and I want to change
it from Teacher to Student. Given that I guess the PK cannot be
changed, as it's the key for joining other tables. How should I do
that?
1. should I directly update using merge(), or
2. should I put the information to a new Student object, and use
persist(), or
3. should I remove the instance from Teacher first
Thanks,
Harry