I'm writing a JPA entity and want it's id to be generated automatically by Hibernate. I'm using @GenericGenerator
annotation with some parameters managing strategy and increment. I want ids to be generated consequently (1, 2, 3, 4, ...), but somehow Hibernate decides that it must be generated by incrementing previous id by 100 (1, 101, 201, ...).
BTW I'm using Derby Embedded.
I found that strategy = "increment" fits my aim but as I understand it's type isn't thread safe.
@Table(name = "ACCOUNTS")
data class Account(
@Id
@GenericGenerator(name = "ACCOUNT_SEQ",
strategy = "enhanced-sequence",
parameters = [
Parameter(name = "initial_value", value = "1"),
Parameter(name = "increment_size", value = "1")]
)
@GeneratedValue(generator = "ACCOUNT_SEQ")
@Column(name = "ID")
val id: Long
)
So, how can I use strategy = "enhanced-sequence" and increment id by 1? Is it possible?