Hi,
we have deployed Spring 3 + Hibernate application on 2 load balancing servers. the issue is with the Hibernate sequence generator. after 50 insertions into the Database, hibernate is not calling the DB sequence nextval, it continuously incrementing the count. And due to this the sequence values from both the servers are overlapping and I am getting "Unique Constraint Violation" exception.
E.g. Say, first time the sequence values from both the servers are 100 and 150 respectively. When the sequence of first instance reaches 149, it is supposed to call seq.nextVal. But since it is not doing so and continuously incrementing the seq value to 150 which is used by other instance and it is failing. default allocationSize: 50
@Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "CUSTOMER_ID_SEQ") @SequenceGenerator(name = "CUSTOMER_ID_SEQ", sequenceName = "CUSTOMER_SEQ") @Column(name = "CUST_ID", unique = true, nullable = false) public long getCustId() { return custId; }
Could one help on this issue. Thanks in advance.
|