insertable parameter of Colum annotation doesn't want to work
843859Aug 22 2008 — edited Aug 26 2008I was trying to write an entity class, with integral primary key. I've designed a table in the way, that the primary key'd be inceremented automatically by the database itself. I've coded the entity in the following manner:
@Id
@Column(name="ID", nullable=false, insertable=false)
private int id
...
The entity class works well while retrieving data from the database, but problems appear when I want to persist new entity instances. The problem is, that even though the id persistent field was annotated as non-insertable, the insert query includes it anyway, causing error to occur, since the database won't accept the field, since it should be incremented automatically. It looks as if the 'insertable' parameter was ignored.
If there is no id persistent field in the class, entities are persisted without any problems.
I'm using 64-bit MS SQL Server 2008 with JDBC 1.2. avaliable on microsoft's webpage.
Has anyone an idea what the problem is?