0 Replies Latest reply on Apr 24, 2003 12:33 PM by tyang

    unknown-pk always return BigDecimal with Oracle

    tyang Newbie

      When i use the unknown-pk mechanism in Jboss 3.2.0 with Oracle 9i to generate primary keys, regardless how i configure it in jbosscmp-jdbc.xml, the primary key I got is always of type java.math.BigDecimal. To get around I have to transform it into java.lang.Integer type, which is really what I want. It looks to me that the unknown-pk-class, jdbc-type, or sql-type configurations are ignored by jboss. For unknown-pk-class, you can have java.lang.Long, java.lang.Object or whatever, jdbc-type can be NUMERIC, INTEGER or whatever, the same BigDecima is returned.

      This problem applies to Oracle 8i also. Does anybody else have this problem? Do i miss something here, or it's sopposed to be working like this?

      Here is the the relevent code and configs

      ejb-jar.xml


      <ejb-name>PKTest</ejb-name>
      <local-home>com.ersus.test.PKTestLocalHome</local-home>
      com.ersus.test.PKTestLocal
      <ejb-class>com.ersus.test.PKTest</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>java.lang.Object</prim-key-class>
      False
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>PKTest</abstract-schema-name>
      <cmp-field>
      <field-name>name</field-name>
      </cmp-field>
      <security-identity>
      <use-caller-identity/>
      </security-identity>


      jbosscmp-jdbc.xml


      <ejb-name>PKTest</ejb-name>
      java:/ORACLEDS
      <datasource-mapping>Oracle9i</datasource-mapping>
      <create-table>false</create-table>
      <remove-table>false</remove-table>
      <read-only>false</read-only>
      <table-name>PKTEST</table-name>
      <cmp-field>
      <field-name>name</field-name>
      <column-name>NAME</column-name>
      </cmp-field>
      <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 PKTEST_SEQ.NEXTVAL FROM DUAL
      </entity-command>



      Java code:

      try{
      InitialContext ctx = getInitialContext();
      Object obj = ctx.lookup("PKTestLocal");
      PKTestLocalHome test_lh = (PKTestLocalHome)obj;
      PKTestLocal test = test_lh.create("test name");
      logger.info(test.getPrimaryKey().getClass().getName());
      }catch(Exception e){
      e.printStackTrace();
      }