-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Hibernate convert data between object versions
PostPosted: Thu Sep 08, 2011 5:50 am 
Newbie

Joined: Thu Sep 08, 2011 5:30 am
Posts: 1
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.