Environment:
Hibernate5.1, JPA1.8, Oracle12, Spring 4.3.9
Sequence:
CREATE SEQUENCE "SEQ_PROBLEM" MINVALUE 0 MAXVALUE 9999999999 INCREMENT BY 1 START WITH 1 CACHE 100 NOORDER NOCYCLE;
Entity Config:
@Id
@SequenceGenerator(name = "PROBLEM_ID_GENERATOR", sequenceName = "SEQ_PROBLEM", allocationSize = 50)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "PROBLEM_ID_GENERATOR")
private long id;
Test Step:
- Start one server, and save the entity, success.
- Start the other server, and save the entity, I get the "unique constraint violation" error.
java.sql.SQLIntegrityConstraintViolationException: ORA-00001: unique constraint (******.PK_PROBLEM) violated
I checked the code, and the PooledOptimizer class do not apply the 50 sequences from oracle, so I guess that the second server cannot get the correct sequence number. As performance reason that I do not want to set the allocationSize as 1. Any ideas for this situation? thanks.