我将使用序列作为主键。我在eclipse中使用hibernate工具来生成ORM。我无法确定在java bean中提及ID序列的选项。
像
@Id
@GeneratedValue(strategy = GenerationType.AUTO, generator = "G1")
@SequenceGenerator(name = "G1", sequenceName = "LOG_SEQ")
@Column(name = "ID", unique = true, nullable = false, precision = 22, scale = 0)
public int getId() {
return this.id;
}
有没有办法提及它并用它生成bean类?
答案 0 :(得分:0)
在下面的定义中,LOG_SEQ是数据库中该ID应该用于生成值的序列的名称
@SequenceGenerator(name = "G1", sequenceName = "LOG_SEQ")
有无
java.lang.String sequenceName
(Optional) The name of the database sequence object from which to obtain primary key values.
最后,您应该将sequenceName替换为数据库模式中考虑使用
的序列注释的架构属性,看看here