Hi,
I am new user of hibernate.
I am trying to merge between tables of 2 databases,
meaning for each table read all records from first DB and insert to the second DB only the records that don't already exist.
I have 2 sessionFactory, one for each DB.
For each table in the first database, I am using the session.find method to select all records to a List.
Each object in the List I am inserting by session.save...
My questions:
First, Is that the elegant way of doing that?
Second, for inserting only records that don't already exist, am I suppose to use session.get before use session.save on each object? (isn't this a bad performance?)
or can I use directly session.save and there is a specific exception thrown in case of duplicate-key that I can catch and ignore that case and continue to the next object in the list?
|