views:

93

answers:

1

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 ?

+1  A: 

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") })
Hardy