java - Hibernate composite keys with abstract class -
is possible have employee table composit primary key (personid,departmentname) keeping
the person's class @id annotation , keeping abstract class.
public abstract class person { @id @generatedvalue @column(name = "person_id") private long personid; @column(name = "firstname") private string firstname; // getter , setter methods, } @entity @table(name="employee") @primarykeyjoincolumn(name="person_id") public class employee extends person { @column(name="joining_date") private date joiningdate; @column(name="department_name") private string departmentname; public employee() { } public employee(string firstname, string lastname, string departmentname, date joiningdate) { super(firstname, lastname); this.departmentname = departmentname; this.joiningdate = joiningdate; } // getter , setter methods, }
Comments
Post a Comment