Calling CrudRepository save() method for an entity that is NOT new creates following sql: UPDATE card SET id = ?, customer_id = ? ... WHERE id = ?
This raises exception Cannot update identity column 'id'
ID is generated by the database
used version: 1.0.6.RELEASE & 1.0.9.RELEASE
DB: mssql
Why is update statement trying to update the ID column as it is the primary key?
Entity:
import org.springframework.data.annotation.Id;
import org.springframework.data.relational.core.mapping.Column;
import org.springframework.data.relational.core.mapping.Table;
@Table("card")
public class Card {
@Id
private Long id;
@Column("customer_id")
private String customerId;
...
Repository:
public interface CardRepository extends CrudRepository<Card, String> {
}