I have a jpa configuration like this:
@Id
//@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="seq_gen")
@GeneratedValue(generator = "timedep_seq_gen")
@GenericGenerator(
name = "seq_gen",
strategy = "org.hibernate.id.enhanced.SequenceStyleGenerator",
parameters = {
@Parameter(name = "sequence_name", value = "sequence_myseq"),
@Parameter(name = "initial_value", value = "1"),
@Parameter(name = "increment_size", value = "10"),
@Parameter(name = "optimizer", value ="hilo")
}
)
private Long id;
The insertions are creating id values like 1,2,3.. and this is fine till I manually do
SELECT nextval('sequence_myseq');
I expect that on running the above from pgadmin(or any other client), the next set of values generated by the jpa/hibernate generator should skip the values for the id column, but that is not the case. It still generates the values without skipping any id values. What is the problem here ?
EDIT 1
Till I get some concrete answer, looks like hilo
optimization will not work for multiple instances. The following is working but it needs you to set
increment by 10
in your sequence definition as well.
@GeneratedValue(generator = "dep_seq_gen")
@SequenceGenerator(
name = "dep_seq_gen",
sequenceName = "sequence_dep",
allocationSize = 10
)