Auto-Increment-Identifier-With-MSSQL-And-Hibernate
If you’re using MSSQL Server and wondering about this error message produced by Hibernate:
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Cannot insert explicit value for identity column in table '<TABELNAME>' when IDENTITY_INSERT is set to OFF.
you’re annotated classes are maybe missing the @GeneratedValue annotation for the Identifier. Something like this:
@Id
@Column(name="MY_ID", unique=true, nullable=false)
@GeneratedValue(strategy=GenerationType.IDENTITY)
public int getMyId() {
return this.myId;
}