-->
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.  [ 2 posts ] 
Author Message
 Post subject: Problem for Convert One child Object to the other
PostPosted: Fri Jun 13, 2008 5:56 am 
Newbie

Joined: Mon Nov 20, 2006 4:08 am
Posts: 3
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.2

Mapping documents:

@Entity
@Inheritance(strategy = InheritanceType.JOINED)
abstract public class Exposure implements Serializable {
......
protected List<BetOption> betOpList;
......
}

@Entity
public class ExposureNew extends Exposure

@Entity
public class ExposureCommited extends Exposure


Name and version of the database you are using:
MySql 5.0


I'd like to Convert and exsiting(in database) instant of Type ExposureNew to that of ExposureCommited .

that means delete record in table ExposureNew
insert record to table ExposureCommited
leave record in table Exposure no changed...

How can i do this?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 13, 2008 10:56 am 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
Well, here's an idea.

Why not load the record first. That gives you the object.

Then, evict the object, so it is detached.

Then, delete the object, so it is gone.

Then, save that object to the new table.

That way, all the same data gets moved around with any of the data getting lost.

So, that's a first iteration. How can we make it better?

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


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

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.