I have a Data Class for Hibernate associated to a table; imagine the Entity Person like this:
@Entity
@org.hibernate.annotations.Proxy(lazy=false)
@Table(name="Person", schema="MySchema")
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
public class ProfileData implements Serializable {
private static final long serialVersionUID = -844564646821609090L;
public PersonData() {
}
@Column(name="idPerson", nullable=false, unique=true)
@Id
...
I need to create historic tables by years of this table: Person2010, Person2011, Person2012… Is it possible without creating new Data Objects? Maybe by a parameter…? I don´t know.
The Entity class is the same, changing the table name and the constructor.
Another one Architecture, more complez but elegant:
YES, You can change the table names using NamingStrategies:
And, when you wanna to use the _year tables, you must to create a session with Hibernate that override rhe table names:
For my architecture I create a session by year and store it into Application map for access when I need it.
Thanks.