-->
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: Mapping same object to two different tables
PostPosted: Thu Dec 09, 2004 6:55 am 
Newbie

Joined: Thu Dec 09, 2004 6:18 am
Posts: 1
Hi,

I am faced with a problem where i have to persist the same object to two different tables at different times.

More specifically, I have an object that needs to be put into a table, say RECORD. I have another table RECORD_HISTORY which has the same columns as the RECORD table. My business requirement needs me to move the record in the RECORD table into the RECORD_HISTORY table when the user deletes a record.

Do i need to have a separate class for persisting in the RECORD_HISTORY table ? If not, how can i specify at run time which mapping file the object should use to persist itself ...

It is my guess that i surely need to have two different mapping files, but can the same class be associated with two different mapping files and how do i specify at run time which mapping file this object should use.

Thanks
Prashanth


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 09, 2004 11:10 am 
Regular
Regular

Joined: Thu Oct 07, 2004 4:45 pm
Posts: 92
You can't switch back and forth between two tables at runtime without using more than one SessionFactory.

You might have better luck creating an abstract base class, and have two "empty" subclasses that extend it. Then map each subclass to a different table using table-per-concrete-class inheritance mapping.


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.