Hibernate @TableGenrator表管理主键生成策略
@TableGenerator 是在数据库生成一张表来管理主键生成策略
import
javax.persistence.TableGenerator;
@TableGenerator(
name = "Teacher_GEN", // TableGenerator's name
table = "GENERATOR_TABLE", // 表名
pkColumnName = "pk_key", // 列1,varchar 类型,存储生成ID的键
valueColumnName = "pk_value", 列2,int 类型,存储ID值
pkColumnValue = "Teacher", // 列1的键值
allocationSize = 1 // 增长值
)
public class Teacher {
}
imp
@TableGenerator(
name = "Teacher_GEN", // TableGenerator's name
table = "GENERATOR_TABLE", // 表名
pkColumnName = "pk_key", // 列1,varchar 类型,存储生成ID的键
valueColumnName = "pk_value", 列2,int 类型,存储ID值
pkColumnValue = "Teacher", // 列1的键值
allocationSize = 1 // 增长值
)
public class Teacher {
}