-->
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: How to copy an entity to a different table (or database)?
PostPosted: Thu Jan 22, 2009 12:22 am 
Newbie

Joined: Sun Jun 22, 2008 9:22 pm
Posts: 4
Hi,

Suppose I have a table CustomerAccounts and an associated table Invoices in a database called Northwind_CA.

Using NH, I have an entity class called CustomerAccount, which reference another entity class called Invoice. So far so good.

However, I want to do two things:
1. Copy an entity from CustomerAccounts to a another table called CustomerAccountsBackup (and similarly for all its associated members).
2. Copy an account entity (and its associated entities) from database Northwind_CA to Northwind_US.

For #1, the way I am doing involves creating a set of entity classes for CustomerAccountsBackup and its related tables, and write a clone method which creates an entity of type CustomerAccountBackup, and copy its value from an entity of type CustomerAccount, and perform similar action for its associated entries.

For #2, I am doing similar thing, but now for different databases, instead of for different tables.

I wonder if there is a simpler way to achieve that in Hibernate?

Thanks,
- Patrick


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.