Hibernate Annotation for Entity existing in more than 1 catalog
Posted
by user286395
on Stack Overflow
See other posts from Stack Overflow
or by user286395
Published on 2010-03-04T16:08:56Z
Indexed on
2010/05/02
17:07 UTC
Read the original article
Hit count: 194
I have a Person entity mapped by Hibernate to a database table in a database catalog "Active". After a period of time, records in this database table in the "Active" catalog are archived/moved to an exact copy of the table in a database Catalog "History". I have the need to retrieve from both the Active and History Catalogs. Is there a better way to model this with Hibernate annotations than making an abstract class that 2 classes extend from.
This is what I have now.
@MappedSuperclass
public abstract class Person {
@Id
private Integer id;
private String name;
}
@Entity
@Table(name="Person", catalog="Active")
public class PersonActive extends Person {
}
@Entity
@Table(name="Person", catalog="History")
public class PersonHistory extends Person {
}
© Stack Overflow or respective owner