Hi All
We generally put 4 field in every table named as CREATED_BY , LAST_UPDATED_BY , CREATION_DATE, LAST_UPDATED_DATE , So i thought why not put this in single class BaseDo and than inherit this into the class like EmployeeDo. The problem is if i annotate this BaseDo with @Entity i have to put one @Id field which i do not want . Is there a way to achieve this ?
@Entity
@Inheritance(strategy=InheritanceType.TABLE_PER_CLASS)
public class BaseDo implements Serializable {
private static final long serialVersionUID = 6685603264139140757L;
@Column(name="CREATED_BY" , nullable =false )
private String createdBy;
@Column(name="LAST_UPDATED_BY", nullable =false )
private String lastUpdatedBy;
@Column(name="CREATION_DATE", nullable =false )
private Date creationDate;
@Column(name="LAST_UPDATED_DATE", nullable =false )
private Date lastUpdationDate;
}
@Entity
@Table(name="EMPLOYEE")
public class EmployeeDo extends BaseDo implements Serializable {
private static final long serialVersionUID = 4465521188079217243L;
@Id
@Column(name="EMPLOYEE_ID" )
private String employeeId ;
}
Thanks A Lot
you should use @MappedSuperclass
Please check it
http://docs.oracle.com/javaee/5/api/javax/persistence/MappedSuperclass.html