1 Reply Latest reply on May 24, 2002 1:44 AM by Christoph Grimm

    JBOSS 2.4.6 primkey Error message

    Sundaram Ramasamy Newbie

      Hi

      I am getting following error in JBoss-2.4.6_Tomcat-4.0.3. I don't know what I am doing wrong.

      Error
      ----
      [ERROR,ContainerFactory]
      Bean : RoomService
      Section: 9.4.7.1
      Warning: The type of the field named in the primkey-field element must match the
      class in the prim-key-class element.

      ejb-jar.xml
      -----------


      <display-name>RoomService</display-name>
      <ejb-name>RoomService</ejb-name>
      com.percipia.ptce.xmlapps.RoomServiceHome
      com.percipia.ptce.xmlapps.RoomService
      <ejb-class>com.percipia.ptce.xmlapps.RoomServiceBean</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>java.lang.Integer</prim-key-class>
      False
      <cmp-field> <field-name>itemid</field-name> </cmp-field>
      <cmp-field> <field-name>itemname</field-name> </cmp-field>
      <cmp-field> <field-name>itemdesc</field-name> </cmp-field>
      <cmp-field> <field-name>price</field-name> </cmp-field>
      <primkey-field>itemid</primkey-field>


      jaws.xml
      --------



      DefaultDS
      <type-mapping>mySQL</type-mapping>

      <default-entity>
      <create-table>false</create-table>
      <remove-table>false</remove-table>
      <tuned-updates>true</tuned-updates>
      <read-only>false</read-only>
      <time-out>300</time-out>
      </default-entity>

      <enterprise-beans>

      <ejb-name>RoomService</ejb-name>
      <table-name>roomservice</table-name>
      <create-table>false</create-table>
      <remove-table>false</remove-table>
      <tuned-updates>true</tuned-updates>
      <read-only>false</read-only>
      <time-out>300</time-out>
      <pk-constraint>false</pk-constraint>
      <cmp-field>
      <field-name>itemid</field-name>
      <column-name>itemid</column-name>
      <sql-type>int</sql-type>
      <jdbc-type>INTEGER</jdbc-type>
      </cmp-field>
      <cmp-field>
      <field-name>itemname</field-name>
      <column-name>itemname</column-name>
      <sql-type>varchar(50)</sql-type>
      <jdbc-type>VARCHAR</jdbc-type>
      </cmp-field>
      <cmp-field>
      <field-name>itemdesc</field-name>
      <column-name>itemdesc</column-name>
      <sql-type>varchar(200)</sql-type>
      <jdbc-type>VARCHAR</jdbc-type>
      </cmp-field>
      <cmp-field>
      <field-name>price</field-name>
      <column-name>price</column-name>
      <sql-type>float</sql-type>
      <jdbc-type>FLOAT</jdbc-type>
      </cmp-field>

      </enterprise-beans>


      my MySQL table

      CREATE TABLE roomservice(
      itemid INT NOT NULL AUTO_INCREMENT,
      itemname VARCHAR(50),
      itemdesc VARCHAR(200),
      price float DEFAULT 0 ,
      PRIMARY KEY (itemid));


      my Bean Class
      /**
      * Implementation of Business Methods for RoomService objects.
      */
      public class RoomServiceBean implements EntityBean {
      /* CMP FIELDS AND ACCESSORS */
      public int itemid;
      public int getItemid() { return itemid; }
      public void setItemid(int value) { itemid = value; }
      public java.lang.String itemname;
      public java.lang.String getItemname() { return itemname; }
      public void setItemname(java.lang.String value) { itemname = value; }
      public java.lang.String itemdesc;
      public java.lang.String getItemdesc() { return itemdesc; }
      public void setItemdesc(java.lang.String value) { itemdesc = value; }
      public float price;
      public float getPrice() { return price; }
      public void setPrice(float value) { price = value; }

      /*
      * EJB Create Methods
      */
      public java.lang.Integer ejbCreate(java.lang.Integer id)
      throws CreateException {
      /**
      * @todo You must set the properties of this bean
      * based on what was passed to this create method.
      */
      return null;
      }
      public void ejbPostCreate(java.lang.Integer id) {
      }

      my Home Interface

      public interface RoomServiceHome extends EJBHome {

      /* EJB CREATE METHODS */
      public RoomService create(java.lang.Integer id)
      throws RemoteException, CreateException;


      /* EJB FINDER METHODS */
      public RoomService findByPrimaryKey(java.lang.Integer id)
      throws RemoteException, FinderException;

      public Collection findAll() throws java.rmi.RemoteException, javax.ejb.FinderException;

      }

      any help?



      Sundaram Ramasamy


        • 1. Re: JBOSS 2.4.6 primkey Error message
          Christoph Grimm Newbie

          in your ejb-jar.xml your specified the
          prim-key-class as follows:

          <prim-key-class>java.lang.Integer</prim-key-class>

          and your prim-key-field as

          <primkey-field>itemid</primkey-field>

          while in your entity-bean
          the corresponding field itemid has type int

          public int itemid;

          solution:

          in your entity bean use Integer instead of in as type for field itemid

          or

          create a separate primery key class as a wrapper arround your primitve type