0
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "generator")
@SequenceGenerator(name = "generator", schema = "MD", sequenceName = "sq_base_class")
public Long getId() {
    return id;
}

Hi! I have entity which using MS SQL Sequence for generating ID, but value is incorrect.

com.microsoft.sqlserver.jdbc.SQLServerException: Violation of PRIMARY KEY constraint 'PK_BCL'. Cannot insert duplicate key in object 'MD.BASE_CLASS'. The duplicate key value is (551009).

Example: SequenceGenerator set ID = 551009, but select next value for md.sq_base_class return 551115. How to resolve it? Hibernate-version: 5.3.10.Final

1 Answer 1

1

Maybe you lost the allocation size = 1 in @SequenceGenerator

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.