I have an entity that is using "enhanced-sequence" as strategy. When I use optimizer as "pooled or pooled-lo" I am able insert the rows only if the increment_size value is 1.
If I set increment_size > 1 I see the following error:
Code:
Name:, Time:0, Success:True, Type:Prepared, Batch:False, QuerySize:1, BatchSize:0, Query:["values next value for pooledLo_sequence"], Params:[()]
Name:, Time:0, Success:True, Type:Prepared, Batch:False, QuerySize:1, BatchSize:0, Query:["values next value for pooledLo_sequence"], Params:[()]
FAILED: insertRows
org.hibernate.NonUniqueObjectException: A different object with the same identifier value was already associated with the session : [com.madhu.hibernate.identifiers.jpa.PooledLoSequence#43]
Below is my entity class.
@Entity(name="pooled_lo_sequence_table")
Code:
public class PooledLoSequence {
@Id
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="pooledLo_seq")
@GenericGenerator(name="pooledLo_seq", strategy="enhanced-sequence",
parameters={
@Parameter(name="sequence_name", value="pooledLo_sequence"),
@Parameter(name="initial_value", value="1"),
@Parameter(name="increment_size",value="2"),
@Parameter(name="optimizer", value="pooled")
})
private Long id;
public PooledLoSequence() {
}
}
With the following test code.
Code:
IntStream.range(0, 10).forEach(n -> {
PooledLoSequence row = new PooledLoSequence();
session.persist(row);
});
The hibernate version I am using is 5.0.4 with Derby DB ver 10.12.1.1.
Not sure if I am missing anything or is it a new bug introduced in 5.x?