Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

insertable parameter of Colum annotation doesn't want to work

843859Aug 22 2008 — edited Aug 26 2008
I 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?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 23 2008
Added on Aug 22 2008
2 comments
91 views