更新时间:2022-10-23 22:25:29
SequenceStyleGenerator 应该如此:
@GeneratedValue(generator = SEQUENCE_GENERATOR)
@GenericGenerator(name = SEQUENCE_GENERATOR,
strategy =org.hibernate.id.enhanced .SequenceStyleGenerator,参数= {
@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)})
when using the @GeneratedValue Annotation in Hibernate, and adding a new Entity to DB it has the id 1 ... n . Is is it possible to set the first value, so it would get the id e.g. 10000 ... n ?
SequenceStyleGenerator should to the trick:
@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") })