-->
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: Import /export after table strucure change
PostPosted: Wed Oct 18, 2006 10:19 pm 
Newbie

Joined: Wed Oct 18, 2006 9:39 pm
Posts: 6
Hi,
We have been using hibernate to access oracle. Since our report queries used too many joins we denormalized the table design and merged some of the table. POJO classes were not changed, only the underlying mapping files are changed. We changed some enitty to component and added more fields fields in some table by denormalizing them.

Since our POJO class didn't change, I'm using hibenate to import data from old schema and export to new schema by using two sessionfactories created with two different cfg, and hbm files representing each schema. Using database tools to do import/export is tedious since there is a drastic change in table strucure.

I have simplifed my problem below

1) POJO p = session1.load(...) // uses old schema
// POJO p uses native id gnerator

2) session2.saveOrUpdate(p) // uses new schema

Now the problem is "saveOrUpdate" uses "update" instead of "insert" since the "ID" is available in the POJO. So I changed the code to do

2a) session2.save(p) // uses new schema.

This uses "insert" but the problem is this ignores the value of "ID" in the POJO and creates a new ID.

How to fix this? I want the POJO to be saved(inserted) in the new session with the same primary key. One way is to change the *.hbm file and change the ID proerty to normal attribute, which is messy as i have many files. Is there an elegant solution to this?

Thanks for your toughts.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 19, 2006 2:56 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
session.replicate() (to some extent)

_________________
Max
Don't forget to rate


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.