-
1. Re: autogenerated pk's with cmp entity beans ?
juhalindfors Jul 4, 2003 10:21 AM (in response to rlaenen)I haven't tried it but the 3.2.x jbosscmp-jdbc DTD supports this. Have a look at that file.
-
2. Re: autogenerated pk's with cmp entity beans ?
rlaenen Jul 7, 2003 4:53 AM (in response to rlaenen)After putting
<entity-command name="get-generated-keys"/>
in the defaults section of jbosscmp-jdbc and
<unknown-pk>
<unknown-pk-class>java.lang.Integer</unknown-pk-class>
<field-name>id</field-name>
<auto-increment/>
</unknown-pk>
in the entity section and deploying the stuff,
the Oracle 9.2 jdbc driver came back with an 'unsupported feature' error.
After looking in the jBoss source code the offending statement was :
ps = con.prepareStatement(insertEntitySQL,
PreparedStatement.RETURN_GENERATED_KEYS);
Conclusion, the default Oracle 9 drivers don't support the jdbc type 3 feature that jBoss is using.
I suppose this is linked with the fact that Oracle doesn't know auto-increment columns but makes use of sequences for this.
So, I think we'll need to live with that extra roundtrip to the db for getting the pk-value. -
3. Re: autogenerated pk's with cmp entity beans ?
stephaner Apr 21, 2004 9:15 AM (in response to rlaenen)Hi,
It is a way to configure a autogenerated key for an entity bean for Oracle.
First, you have to create a sequence in DB to generate your PK.
In jbosscmp-jdbc.xml, you have to add the following elements to your entity definition:
Code:
<unknown-pk>
<unknown-pk-class>java.lang.Integer</unknown-pk-class>
<column-name>DB_column_name</column-name>
<jdbc-type>INTEGER</jdbc-type>
<sql-type>NUMBER(8)</sql-type>
</unknown-pk>
<entity-command name="oracle-sequence" class="org.jboss.ejb.plugins.cmp.jdbc.keygen.JDBCOracleCreateCommand">
<attribute name="sequence"\>your_sequence_name
</entity-command> -
4. Re: autogenerated pk's with cmp entity beans ?
sirvaulterscoff Apr 22, 2004 2:25 AM (in response to rlaenen)Its interesting for me to know weather i could use 2 sequinces for one table. I.e. i need one row to have primary key between 1 and 1000000 and the second row - between 1000001 - inf.