-->
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: merge between tables of 2 databases
PostPosted: Sat Aug 27, 2005 2:41 pm 
Newbie

Joined: Sat Aug 27, 2005 2:14 pm
Posts: 5
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?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 31, 2005 10:19 am 
Newbie

Joined: Tue Jul 06, 2004 4:40 am
Posts: 9
Location: Slovakia
Hi

1. consider using Critreria. Find is not in Hibernate3. (try session.createCriteria( Class clazz))

2. Also when you have many objects, List can be problem. (possible OutOfMemory Exception) (try scroll)

3. Try to read ONLY data, that are not in the second database (for example extract Primary Keys from the second and use them in the query on the first database)


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.