Hi!
I've found out that one can use
post-table-create element in
jbosscmp-jdbc.xml to alter the primary key right after table creation to make it auto increment.
Here's the relevant fragment of my XDoclet specification for the entity EJB class:
And here's how the ejbCreate() methods and primary key (productPk) getter look like:
Notice that I've used the
%%t placeholder in the SQL code that will be substituted with the actual table name that JBoss will choose when generating tables.
There's no placeholder for the primary key column name, so one either has to guess, or deploy the app first without the
post-table-create, then see what column name gets generated.
This is for Hypersonic but this technique can obviously be adapted to any RDBMS.
BTW, it would be nice if that trick would be documented in
http://www.redhat.com/docs/manuals/jboss/jboss-eap-4.2/doc/Server_Configuration_Guide/Entity_Commands_and_Primary_Key_Generation-Existing_Entity_Commands.html...
[ June 25, 2008: Message edited by: Aleksander Adamowski ]