1 Reply Latest reply on Mar 4, 2003 1:26 PM by rstinejr

    The class must provide suitable implementation of the hashCo

    grandmst

      I get this INFO output when I deploy my entity beans. I have reviewed the JBoss forms and not found an answer. I have tried the following hashCode() methods and they all still produce the message.

      public int hasCode() {
      return divisionId.hashCode()^departmentId.hashCode();
      }

      public int hasCode() {
      StringBuffer sb = new StringBuffer();
      sb.append(divisionId);
      sb.append(departmentId);

      return sb.toString().hashCode();
      }

      public int hasCode() {
      return this.hashCode();
      }

      I am using jboss-3.0.3_tomcat-4.1.12.

      Here is the message:
      09:56:29,522 INFO [EJBDeployer]
      Bean : com/cybermedtech/acmtv1/DepartmentToDivisionEB
      Section: 10.6.13
      Warning: The class must provide suitable implementation of the hashCode() method.

      Here is the eejb-jar.xml file entry:

      <ejb-name>com/cybermedtech/acmtv1/DepartmentToDivisionEB</ejb-name>
      <local-home>com.cybermedtech.ejb.orgstruct.DepartmentToDivisionHomeLocal</local-home>
      com.cybermedtech.ejb.orgstruct.DepartmentToDivisionLocal
      <ejb-class>com.cybermedtech.ejb.orgstruct.DepartmentToDivisionBean</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>com.cybermedtech.ejb.orgstruct.DepartmentToDivisionPK</prim-key-class>
      False
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>DepartmentToDivision</abstract-schema-name>
      <cmp-field>
      <field-name>divisionId</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>departmentId</field-name>
      </cmp-field>

      <query-method>
      <method-name>findByDepartmentId</method-name>
      <method-params>
      <method-param>java.lang.String</method-param>
      </method-params>
      </query-method>
      <ejb-ql>SELECT OBJECT(o) FROM DepartmentToDivision AS o WHERE o.departmentId = ?1</ejb-ql>


      <query-method>
      <method-name>findByDivisionId</method-name>
      <method-params>
      <method-param>java.lang.String</method-param>
      </method-params>
      </query-method>
      <ejb-ql>SELECT OBJECT(o) FROM DepartmentToDivision AS o WHERE o.divisionId = ?1</ejb-ql>




      Any ideas?

        • 1. Re: The class must provide suitable implementation of the ha
          rstinejr

          Just to clarify -- the class that JBoss is complaining about is the primary key class, com.cybermedtech.ejb.orgstruct.DepartmentToDivisionPK. In your post, it was not clear in which class you had put the hashCode method.

          Also, in your post the methods had the name "hasCode" instead of "hashCode".

          You probably already know this, but in addition to having a hashCode method, DepartmentToDivisionPK will also need to define a public "equals" method, it needs to implement "Serializable", and its instance variables need to be public.