在Hibernate中使用@GeneratedValue Annotation,并在DB中添加新实体时,它的id为1 ... n。 是否可以设置第一个值,因此它将获得id,例如10000 ... n?
答案 0 :(得分:3)
SequenceStyleGenerator 应该诀窍:
@GeneratedValue(generator = SEQUENCE_GENERATOR)
@GenericGenerator(name = SEQUENCE_GENERATOR,
strategy = "org.hibernate.id.enhanced.SequenceStyleGenerator", parameters = {
@Parameter(name = "sequence_name", value = "my_sequence"),
@Parameter(name = "initial_value", value = "1001"),
@Parameter(name = "increment_size", value = "1"),
@Parameter(name = "value_column", value = "my_squence_id") })