In case anyone is watching, I found some documentation for Hypersonic. They allow a special column, called the IDENTITY column. When calling insert on a table which has been created with this column (either as it's own type, or as the default syntax CREATE TABLE <table name> <column name> INTEGER INDENTITY,...) any null value for the column will result in an auto-generated value for the column.
I haven't tried this, but this looks like an alternative to any local generation logic in the Bean or the Container.
I'm curious to see if this works for you. How are you mapping the bean's attribute to the IDENTIY column? I'm thinking that needs to be done so that the bean's findByPrimaryKey methods function correctly.
Please let me know...afschell
Researching on "hypersonic entity-command" brought forth
http://www.jboss.org/modules/bb/index.html?module=bb&op=viewtopic&t= it's not in JBoss 3.2.2, just apply the patch for yourself.
So basically adding a and <entity-command name="hsqldb-fetch-key"/> to your jbosscmp-jdbc.xml at the appropiate place (have a look at the dtd) for each entity with auto-generated id is all there's to it. I would rather recommend to use XDoclet for generating deployment descriptors (editing by hand could be getting annoying sometimes ;-)).
Multiple replies... :)
afschell (I probably misspelled that).. I haven't attempted to name my column to Identity, so I can't confirm or deny that this works.
Reading jcordes link, the hsqldb-fetcch-key calls the INDENTY() method, which appears to do the same thing.
I haven't tried the tag as yet, because I think I need to have a jboss.xml file, and the version that xdoclet generates doesn't seem to work with the version of JBoss I'm using (4.0 ... yes, I'm naughty).
Another annoyance, is that XDoclet doesn't seem to create the CMP part in the ejb-jar.xml either... it leaves out the primary key field, which results in an error when creating the CMP tables. So, I use xdoclet to create the descriptors when I need lots of new entries (like finder methods or relationship definitions) and then copy them into a source which I then use to build into my jar file. Very painful. If nobody picks up on the bug, I may have to look into fixing it myself. ;)