Hello,
I have a problem, and please help, if you can.
Situation is: I already have an application, and this application contains lots of hibernate domain objects with lots of relations. This version is called: 1.0
Now I would like to refactor almost all of the domains. How can I change the database structure without data lose, and how can I copy the data between the old version and new version. For example:
Version 1.0 Domains: @Entity class Class1 { @Id private Integer id;
@ManyToOne private Class2 class2;
private String name; } @Entity class Class2 { @Id private Integer id;
private String description; }
New Version 2.0 Domains: @Entity class Class1 { @Id private Integer id;
// Change directions @ManyToMany private Set<Class2> class2Objects;
// private String name; // not in new version
// In Existing data, I would like to separate the name private String firstName; private String lastName; } @Entity class Class2 { @Id private Integer id;
@ManyToMany private Set<Class1> class1Objects;
private String description;
// This property data generate from code. In existing objects I must generate also. private String uniqKey; }
So How can I change the table structure without data loosing, and how can I convert/generate the existing data? Do it with SQL commands (ALTER TABLE ... UPDATE ...)
Is there any workflow how can I update the very different object domain structure?
Thanks for your help
|