crud

How to autoincrement an Id in a composite primary key in Hibernate?

谁说胖子不能爱 提交于 2020-12-09 09:54:15
问题 I have a table with a composite primary key - groupId and batchId . Entity class looks like: @Entity(name="EMPLOYEE") public class Employee { @EmbeddedId private EmployeePK employeePK; //Other columns and their getters and setters //Getters and setters } Composite PK: @Embeddable public class EmployeePK implements Serializable { private long groupId; private long batchId; @GeneratedValue(strategy=GenerationType.AUTO) public long getBatchId() { return batchId; } public void setBatchId(long

How to autoincrement an Id in a composite primary key in Hibernate?

我与影子孤独终老i 提交于 2020-12-09 09:53:33
问题 I have a table with a composite primary key - groupId and batchId . Entity class looks like: @Entity(name="EMPLOYEE") public class Employee { @EmbeddedId private EmployeePK employeePK; //Other columns and their getters and setters //Getters and setters } Composite PK: @Embeddable public class EmployeePK implements Serializable { private long groupId; private long batchId; @GeneratedValue(strategy=GenerationType.AUTO) public long getBatchId() { return batchId; } public void setBatchId(long