Hibernate Annotation for Entity existing in more than 1 catalog
- by user286395
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 {
}