After couple of sleepless nights I manged to get my CMP bean to work with auto-increment
I am using xdoclet tags so that's how I will descripe the solution
On the entity level
@jboss.entity-command
name="informix-serial"
class="org.jboss.ejb.plugins.cmp.keygen.JDBCInformixCreateCommand"
@jboss.entity-commans-attribute
name="method"
value="getSerial"
On your primary key field "get"
@ejb.pk-field
@ejb.persistence
column-name="id"
jdbc-type="INTEGER"
sql-type="SERIAL"
@jboss.persistence
auto-increment="true"
Thats all you have to do, next time you do ejbCreate() you don't need to provide an Id, jboss and the informix engine will provide you with the key.
Another issue you might run into, which using that auto-incrment key in relations
For example in M:M between two entities which have an auto-increment key. If you don't spcify the "jdbc-type, sql-type" in the jboss.relation, jboss will try to create a table with two serial fields which would fail. So make sure that you specify these two tags when using your auto-increment CMP fileds in a CMR
Thank you thank you THANK YOU!!!!
I've been puzzelled by this for over two years now and finaly a working solution :-)
I can confirm that the same also works for Postgresql 8.3 database.
Thank you!
Wessel