Hibernate中id的table生成策略之联合主键

 

@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生成策略叙述,见

http://blog.csdn.net/woshixuye/article/details/7278119

你可能感兴趣的:(Hibernate,table,Class,generator)