-->
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.  [ 3 posts ] 
Author Message
 Post subject: Question: how to save an entity to a different table
PostPosted: Sun Mar 28, 2010 10:49 am 
Newbie

Joined: Sun Mar 28, 2010 10:37 am
Posts: 2
Hi All,

I have a Class, which its members are mapped to several tables (in the hbm file).
For data purging purposes, I would like to create 'archive' tables (identical to the tables I already have), and move the objects from the original tables to the new ones.

My question is - Do I need to created a new 'archive' Class (same as the original one) and map it to the archive tables, or is there a way to map the original object to the new, archive, tables as well, so I can query the original tables and save the result in the 'Archive' tables.

I hope my question is clear...

Tnx,
Uri


Top
 Profile  
 
 Post subject: Re: Question: how to save an entity to a different table
PostPosted: Mon Mar 29, 2010 4:02 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
One solution could be to use a class hierarchy with table-per-concrete-class strategy:
Code:
@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public abstract class MyBusiness {
...    ///persistent field + property declarations
}

@Entity
public class Original extends MyBusiness { }


@Entity
public class Archive extends MyBusiness { }


In this way you define the class MyBusiness only once with all its properties,
but is mapped with 2 different tables on database (table 'original' + table 'archive')


Top
 Profile  
 
 Post subject: Re: Question: how to save an entity to a different table
PostPosted: Mon Mar 29, 2010 1:47 pm 
Beginner
Beginner

Joined: Wed Sep 06, 2006 12:08 pm
Posts: 48
Location: Warsaw - Poland - Europe - Milky Way
Hi scheiner

We had similar ‘issue’ but we decided to use Oracle partitioning to get such functionality.
To be honest, I am not sure that doing such thing in Hibernate (instead of doing this on database level (partitioning)) is a good idea.

Regards, Adam Woźniak


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