@Entity
@Table(name = "tbl_Student")
public class Student implements Serializable
{
private int id;
private int groupId;
@Id
@TableGenerator(name = "student_gen1", table = "XT_XH", pkColumnName = "TYPE", valueColumnName = "XH", pkColumnValue = "stu1", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.TABLE, generator = "student_gen1")
public int getId()
{
return id;
}
..........................................................................
@Id
@TableGenerator(name = "student_gen2", table = "XT_XH", pkColumnName = "TYPE", valueColumnName = "XH", pkColumnValue = "stu2", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.TABLE, generator = "student_gen2")
public int getGroupId()
{
return groupId;
}
....................................................................
}
详细的id的table生成策略叙述,见