I have the following code in a mapping file. Mapping files are to be replaced by annotations.
So in order to convert it to annotation i need to be able to Map the
same Employee class to two tables
employee and
employeeHistory. Both the tables employee and employeeHistory have exactly the same schema.
org.hibernate.Session object's save(String, Object) was being used to save an Employee object to one of the two tables employee or employeeHistory based on a property. The String was the entity-name attribute from the hbm file. It should not be affected.
I have shown only minimal code from the hbm file
Code:
<hibernate-mapping>
<class entity-name="employee" name="com.esolutions.demo.Employee"
table="employee">
<id name="id" type="java.lang.String">
<column name="id" />
<generator class="assigned" />
</id>
<property generated="never" lazy="false" name="name"
type="java.lang.String">
<column name="name" />
</property>
</class>
<class entity-name="employeeHistory" name="com.esolutions.demo.Employee"
table="employeeHistory">
<id name="id" type="java.lang.String">
<column name="id" />
<generator class="assigned" />
</id>
<property generated="never" lazy="false" name="name"
type="java.lang.String">
<column name="name" />
</property>
</class>
</hibernate-mapping>
How can I do it using annotations. I am using hibernate core version 3.6.7
Any help is appreciated.