我需要下一个功能。低于值
@Column(name = "incomeNumber", unique = true, nullable = false)
private int incomeNumber;
必须从1开始并自动增加。我如何用hibernate设置它?
答案 0 :(得分:1)
@GenericGenerator(name="incgenerator" , strategy="increment")
@GeneratedValue(generator="incgenerator")
@Column(name = "incomeNumber", unique = true, nullable = false)
private int incomeNumber;
答案 1 :(得分:0)
按照D. Pineda的想法加上一个默认值,如果你从1开始; Setting default values for columns in JPA