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
|