[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.rt.eclipselink] Database generated primary key - problems with insert

I am working with a database where primary key (INTEGER) is generated by the database.

The DDL for the field of that table is

xfrCtrlKey FOR COLUMN XFRKY INTEGER GENERATED ALWAYS AS IDENTITY (START WITH 5 INCREMENT BY 5),

The server rejects the SQL executed by DatabaseSession.insertObject(). The error returned is:

Internal Exception: java.sql.SQLSyntaxErrorException: [SQL0798] Value cannot be specified for GENERATED ALWAYS column XFRCTRLKEY.

How can I get around this?

I tried several methods to exclude XFRCTRLKEY from the INSERT SQL
- custom SQL in Workbench
- session.getDescriptor(Xfrctl00.class).getQueryManager().setInsertSQLString
- create an InsertObjectQuery, setHintString(), then execute


These would all change the INSERT portion of the SQL but session.insertObject() and session.executeQuery() would still put the value of the primary key into the parameter list

INSERT INTO .... VALUES(? (xfrCtrlKey) ? ... ?)

I finally got around the problem with
session.getDescriptor(Xfrctl00.class).getQueryManager().setInsertSQLString()
and building the full INSERT SQL without the primary key.


Not a good solution!

I spend the better part of a day on this. In my search I ran across a hint that Eclipselink identy annotators could be used for this situation.

?? Can Ecliselink annotators be used to prevent the database insert from including the primary key in this situation? If so, how?????

Does anyone have any other ideas?

Thanks for your time.

Bill Blalock