-->
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: syncronize DB data
PostPosted: Thu Aug 07, 2008 4:09 pm 
Newbie

Joined: Thu Aug 07, 2008 4:04 pm
Posts: 1
Hi,

I am trying to syncronize data from one database to another using Hibernate.

Hibernate version: hibernate-3.2
Name of the database I am using: MS SQL Server 2005

My tables use generated identifiers as primary keys.
I use the name of an object as its natural id. For example,

Database 1 has table customer with one row having values cust_id=100, cust_name="ABC" and cust_address="XYZ"
Database 2 has table customer with one row having values cust_id=500, cust_name="ABC" and cust_address="XYZ"

Both these rows represent the same information since they have the same cust_name "ABC". Now if cust_address is updated in DB1 from "XYZ" to "XYZ1", I want it to get syncronized with DB2 at some point later. I used hibernate to reverse engineer my DB schema and I got my mapping files and some POJO's. I query the data in DB1, with lazy loading set to false. Therefore, all data corrosponding to child objects gets populated in my POJO.

I then detach the hibernate object and send it over the network as a XML stream. On the other side, I deserialize the XML and get the hibernate POJO back as it was. Now the POJO contains other objects as members forming an object graph. I am assuming that I can now save this object to the database using saveOrUpdate. However, the POJO I have contains identifiers for the contained objects and I get errors when I try to perform the save. Is it possible to indicate to hibernate to ignore the id feilds populated in my POJO ? Can I somehow save my POJO that I transferred over the wire to my new database ?

Let me know in case you need more information.

Thanks,
Amol


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 08, 2008 4:19 am 
Beginner
Beginner

Joined: Wed Jul 09, 2008 5:34 am
Posts: 41
Location: Brno, Czech Republic
So, your ID (identificator) in the DB which is getting the data is the customer name? If so, what will you do with the "cust_id"?

It seems to me that you need to use the cust_name as ID in the receiving table and use cust_id as just another property.


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.