3 Replies Latest reply on Feb 9, 2004 1:36 PM by sesques

    java.lang.NullPointerException with database generated key i

    sesques Novice

      Hi,

      I'm new to JBOSS and I have problems with my Entity CMP mapped to SQL Server 2000. I work with ECLIPSE 2.1.2, JBOSS IDE 1.2.2 and JBOSS server 3.2.3.

      I can read without any problem the tables through the entity bean but when I want to create a new item, I throw an exeption:
      java.lang.NullPointerException at org.jboss.ejb.plugins.cmp.jdbc.keygen.JDBCSQLServerCreateCommand.executeInsert(JDBCSQLServerCreateCommand.java:64)

      My CMP entity bean is declared as follows:

      /**
      * @ejb.ejb-ref
      * ejb-name="PhML_Repxml"
      * view-type="local"
      *
      * @ejb.bean description="PharmaML Requete XML"
      * display-name="PhML_ReqxmlBean"
      * local-jndi-name="ejb.PhML_ReqxmlBeanHome"
      * name="PhML_Reqxml"
      * type="CMP"
      * cmp-version="2.x"
      * view-type="both"
      *
      * @ejb.home
      * local-class="PharmaML_EJB.interfaces.PhML_ReqxmlHome"
      * remote-class="PharmaML_EJB.interfaces.PhML_ReqxmlRemoteHome"
      * @ejb.interface
      * local-class="PharmaML_EJB.interfaces.PhML_Reqxml"
      * remote-class="PharmaML_EJB.interfaces.PhML_ReqxmlRemote"
      *
      * @ejb.pk class = "java.lang.Long"
      *
      * @jboss.unknown-pk
      * class="java.lang.Long"
      * column-name="REQXML_ID"
      * field-name="reqxmlId"
      * jdbc-type="NUMERIC"
      * sql-type="NUMERIC"
      * auto-increment="true"
      * readonly="true"
      *
      * @jboss.persistence
      * datasource="java:/dsPharmaML"
      * datasource-mapping="MS SQLSERVER2000"
      * create-table="false"
      * remove-table="false"
      * table-name = "TD_REQXML"
      *
      * @ejb.persistence
      * table-name = "TD_REQXML"
      *
      * @jboss.entity-command name = "mssql-fetch-key"
      *
      */

      and the jbosscmp-jdbc.xml look as follows:


      <ejb-name>PhML_Reqxml</ejb-name>
      java:/dsPharmaML
      <datasource-mapping>MS SQLSERVER2000</datasource-mapping>
      <create-table>false</create-table>
      <remove-table>false</remove-table>
      <table-name>TD_REQXML</table-name>

      ... columns

      <unknown-pk>
      <unknown-pk-class>java.lang.Long</unknown-pk-class>
      <field-name>reqxmlId</field-name>
      <read-only>true</read-only>
      <column-name>REQXML_ID</column-name>
      <jdbc-type>NUMERIC</jdbc-type>
      <sql-type>NUMERIC</sql-type>
      <auto-increment/>
      </unknown-pk>
      <entity-command name="mssql-fetch-key">
      </entity-command>

      Someone can help ?
      Thanks