I have an application A with a domain-model which is mapped to a database using Hibernate. I have another application B that uses exactly the same domain-model-classes as A and adds some additional classes.
My goal is to read data from database A in application B and transfer that data into the database of B (to make a copy of it). In addition, some the domain-classes of B have associations (OneToOne) to domain-classes of A (but in the database of B, of course).
What’s the best strategy to accomplish this? I thought of two session factories and using Session.replicate() (how does that work?). Or should I better introduce an additional mapping layer between these two domain-models for loose coupling?
I’ve done this before to transfer data between two different database types (in my case DB2 and MS SQL Server). What I did was to create two separate session factories, and give both of them the same list of mapping files. Then I simply read records from one, and saved them to the other.
Of course, this assumed that both data sources were identical.