Cannot persist a new record due to IDENTITY_INSERT is set to OFF

If the Order_Sequence column is the IDENTITY, then the Primary Key column must be manually assigned.

If that’s the case, then the ID column must be mapped like this:

@Id
@Column(name = "ID")
private Long id;

while the Order_Sequence column will be mapped as follows:

@Generated( value = GenerationTime.INSERT)
@Column(name = "Order_Sequence")
private Long orderSequence;

Try it like this and let me know how it works.

1 Like