I have been trying to set up auto-increment primary keys with CMP using MS SQL, but have run into some problems. Now, I am not sure if it is even possible at this point since I have found some conflicting opinions on the topic
It seems that JBoss (I'm using version 3.2.0RC3) recognizes the <auto-increment> tag within my primary-key cmp field in jbosscmp-jdbc.xml. However, I unsuccessfully tried a number of entity commands, including a custom one, to retrieve the generated key from my SQL 2000 database. The error I keep getting is:
Failure while creating an OrderEntity bean: Entity with primary key [.0.] already exists
I don't have a primary key with the value '0', but I'm also not sure my entity command is correct:
SELECT (IDENT_CURRENT('tOrder') + 1)
I haven't been able to understand how entity commands are used during the create method. Are they used BEFORE the actual insert, or AFTER(the above SQL command will return the next pk before the insert). Futhermore, I am not sure which entity commands are used in what way?
Has someone gotten this to work? It seems that all JBoss would have to do is to retrieve the key somewhere before/during/after executing my ejbCreate using my defined entity command, and insert a row into the DB without setting the PK field.
Any insights are greatly appreciated.