Replace a hibernate persisted class with its sibling class -


I am working on a project using Hibernate to continue my organizations (Straits 2, Spring, JPA and Hibernate).

I have two classes list and pie , and both get from a widget class ( InheritanceType.JOINED ). I can not find my head around this situation: I have maintained a list in the database but now I want to change it with the Pie unit How do I do this? Can i

The only thing that I am making another unit, I can copy the general properties, delete the old one and the new one (with a different ID) is a transaction

Do you know this in any other way?

Thank you very much.

One option is to use the original query to modify the stored unit directly. If you are using a discriminating pillar, you can modify the stored value in the column for Class A and change it to the value required for Class B. You will also need to modify existing data to match the new category.

I am referring to this as an alternative approach, but I am not saying that this is a recommended approach. Using this technique can cause problems with caching and affect any living object.

The approach you have mentioned is a clean perspective that you can use within JPA space.

Edit

This approach works for all legacy strategies For joint and TABLE_PER_CLASS legacy you need written questions which Any distortional column changes need to be migrated along with the data of the middle, which you may have to set based on the strategy you use

In the long run, this approach is your application Maintenance of Can significantly affect. One advantage of the approach you have mentioned is that you can take advantage of the quick copy of the common field between two objects, which simplifies future maintenance.

Comments