How to use existing Oracle sequence to generate id in hibernate?
hibernate, oracle, sequence
Solution
The answer to the original question:
@SequenceGenerator(name="EL_SEQ", sequenceName="EL_SEQ",allocationSize=1)
It is `allocationSize` that sets the value to increment by.
Problem
I have legacy Oracle db with a sequence named `PRODUCT_ID_SEQ`. Here is the mapping of `Product` class for which I need generate correct ids: ``` public class Product { @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "retailerRaw_seq") @SequenceGenerator(name = "retailerRaw_seq", sequenceName = "PRODUCT_ID_SEQ") private Long id; ... } ``` But looks like ids are generated with an interval of 50, like 1000, 1050, 1100 etc. This corresponds to the default value of `allocationSize` property = 50. So that means that Hibernate doesn't actually use the sequence which is already defined in the db. How do I make Hibernate use the sequence?