0 Replies Latest reply on Apr 1, 2003 4:52 PM by Hugo

    Generated Keys and Oracle

    Hugo Newbie

      Jboss 3.2.0RC4 seems to work nice with generated keys, but i ran into some problems. I created a little test bean with an unknown primary key and a String value. Both the ejb-jar.xml; and the jbosscmp-jdbc.xml file have the correct entries as far as i was able to figure out. Still calling the create method on my test bean fails. The trace included below shows what happens; it retrieves the primary key, no problem, but then it tries to verify that the key isn't in use. That fails with a class cast exception somewhere in the oracle jdbc classes.

      anybody any idea what is going on and why this is happening? More important even, how i can solve this?

      ejb-jar.xml snippet:

      Models a Koekje
      <ejb-name>KoekjeEjb</ejb-name>
      org.dvddb.ejb.backend.KoekjeHome
      org.dvddb.ejb.backend.KoekjeEjb
      <ejb-class>org.dvddb.ejb.backend.KoekjeBean</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>java.lang.Object</prim-key-class>
      False
      <abstract-schema-name>Koekje</abstract-schema-name>
      <cmp-field><field-name>koekje</field-name></cmp-field>




      jbosscmp-jdbc.xml snippet:

      <ejb-name>KoekjeEjb</ejb-name>
      <table-name>koekje</table-name>
      <unknown-pk>
      <unknown-pk-class>java.lang.Integer</unknown-pk-class>
      <field-name>id</field-name>
      <column-name>id</column-name>
      <jdbc-type>INTEGER</jdbc-type>
      <sql-type>NUMBER(10)</sql-type>
      </unknown-pk>
      <entity-command name="pk-sql">
      select koekje_id_seq.nextval from dual
      </entity-command>


      tracelog snippet:
      2003-04-01 22:56:08,278 TRACE [org.jboss.ejb.plugins.EntityInstancePool] Get instance org.jboss.ejb.plugins.EntityInstancePool@15c0729#0#class org.dvddb.ejb.backend.KoekjeBean
      2003-04-01 22:56:08,280 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCPkSqlCreateCommand.KoekjeEjb] Executing SQL: select koekje_id_seq.nextval from dual
      2003-04-01 22:56:08,311 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCPkSqlCreateCommand.KoekjeEjb] Create: pk=3
      2003-04-01 22:56:08,312 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCPkSqlCreateCommand.KoekjeEjb] Executing SQL: SELECT COUNT(*)
      FROM KOEKJE WHERE id=?
      2003-04-01 22:56:08,313 TRACE [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.KoekjeEjb.id] Set parameter: index=1, jdbcType=INTEGER, value=3
      2003-04-01 22:56:08,313 ERROR [org.jboss.ejb.plugins.cmp.jdbc.JDBCPkSqlCreateCommand.KoekjeEjb] Error checking if entity existsjava.lang.ClassCastException
      at oracle.jdbc.driver.OraclePreparedStatement.setObject(OraclePreparedStatement.java:2021)
      at oracle.jdbc.driver.OraclePreparedStatement.setObject(OraclePreparedStatement.java:2102)
      at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.setObject(WrappedPreparedStatement.java:607)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCUtil.setParameter(JDBCUtil.java:280)
      at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCAbstractCMPFieldBridge.setArgumentParameters(JDBCAbstractCMPFieldBridge.java:301)
      at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCAbstractCMPFieldBridge.setPrimaryKeyParameters(JDBCAbstractCMPFieldBridge.java:289)