-->
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.  [ 5 posts ] 
Author Message
 Post subject: Mapping objects to different sets of tables
PostPosted: Fri Feb 20, 2004 8:01 pm 
Newbie

Joined: Thu Oct 02, 2003 2:02 pm
Posts: 4
I have a group of tables that persist customers' data. At certain points in my application I need to take a snapshot of that data and insert it into an identical but distinct table structure which represents the customer's history trace.

In other words, I have a bunch of tables such as CUSTOMER, APPLICATION, etc. related together and I need the same set of Java objects be able to persist themselves to a different set of tables ie. CUSTOMER_HISTORY, CUSTOMER_APPLICATION etc.
The fields and relations in the _HISTORY tables are identical to the main set of tables so I really don't feel like creating a brand new set of Java classes just to be able to do that. What I need is a clone of the original data in those _HISTORY tables except with all the foreign keys and primary keys regenerated.

Is there a way for Hibernate to dynamically change where its stuff gets persisted or do I need a brand new set of sibling objects mapped to my _HISTORY tables in order to do what I'm trying to do?

All the tables are in the same schema.

Anyone with a suggestion on how to best handle this?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 20, 2004 8:32 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
you might be able to do it with a second SessionFactory with different mapping.

In Hibernate 2.2 it will be easier.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 20, 2004 8:40 pm 
Newbie

Joined: Thu Oct 02, 2003 2:02 pm
Posts: 4
Thanks Gavin,

When is 2.2 scheduled for and what's in it that is going to make my problem easier to resolve?

Thanks for a prompt reply.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 20, 2004 8:45 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
As usual, there is no schedule.

But not for at least 6 months.

The feature is support for "named" entities, eg.

session.get("AccountLog", id)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 20, 2004 8:53 pm 
Newbie

Joined: Thu Oct 02, 2003 2:02 pm
Posts: 4
Thanks again for your reply. Hibernate is so unbelievably cool I don't want to build another web app without it :-)

The timeline for 2.2 is not alingned with my project's deadline (due in a few weeks) so I think I'll just do it the hard way and have a replica set of Java objects. Still a far better option than messing with triggers ans stored procedures.

Thanks for your work on this wonderful tool.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.