unknown pk beans - db2
jornik Oct 27, 2004 4:21 AMHi!
I have a bean which is defined with an unknown primary key.
The bean has a jbosscmp-jdbc.xml file associated where the pk is specified.
It all works fine in the hypersonic db and jboss 3.2.5, but when bringing it to our real db environment, db2 7.2, I get the following problems:
At deployment:
create table error:
10:07:19,053 ERROR [EntityContainer] Starting failed jboss.j2ee:jndiName=local/TestT,service=EJB org.jboss.deployment.DeploymentException: Error while creating table IMAGE; - nest
ed throwable: (COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][DB2/LINUX] SQL0104
N An unexpected token "," was found following "ER NOT NULL IDENTITY". Expected t
okens may include: "<references_spec>". SQLSTATE=42601
)
at org.jboss.ejb.plugins.cmp.jdbc.JDBCStartCommand.createTable(JDBCStartCo
...
This is not a show stopper problem. I could create the tables myself, and so I did...
At runtime: (after I created the tables myself...)
primary key generation error
-----------------------------------------------------------------------------------
09:58:55,850 ERROR [ImageCollection] Could not create entity
COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][DB2/LINUX] SQL0798N A value cann
ot be specified for column "ID" which is defined as GENERATED ALWAYS. SQLSTATE=42
8C9
at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_SQLException(SQLExcept
ionGenerator.java:267)
at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_SQLException(SQLExcept
ionGenerator.java:209)
at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.check_return_code(SQLExcepti
onGenerator.java:455)
at COM.ibm.db2.jdbc.app.DB2PreparedStatement.execute2(DB2PreparedStatement
----------------------------------------------------------------------------
This I get when I rely on the default entity command. (none specified)
What <entity-command> should be used for db2? (I have seen posts on one called DB2IdentityValLocalCreateCommand which seem to be the right one, but when adding an entity command myself for this class, the classfile is not found...)
For the working hypersonic sql, I use <entity-command name="hsqldb-fetch-key"/>
This is my pk definition in the jboss file
<unknown-pk>
<unknown-pk-class>java.lang.Integer</unknown-pk-class>
<column-name>ID</column-name>
<jdbc-type>INTEGER</jdbc-type>
<sql-type>INTEGER</sql-type>
<auto-increment/>
</unknown-pk>
When I created the tables myself, I made an ID column as follows
ID INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY ( START WITH +1 , INCREMENT BY +1 , CACHE 20 )
Any clues on this?