2 Replies Latest reply on Dec 20, 2001 8:57 AM by Marcus Brito

    Deploying with Primary Key class

    David Hickman Newbie

      I am using JBoss 2.4.1a, when I deploy the EJB I get an error message that 'the primary key class must override hashCode()', can anyone help with the structure of this method?

      Thanks, Dave

        • 1. Re: Deploying with Primary Key class
          Klaus Thiele Newbie

          try like this:

          public class anmeldungPK implements java.io.Serializable {

          public String man;
          public String ak;
          public String pnr;

          public anmeldungPK() { }

          public anmeldungPK(String man, String ak, String pnr) {
          this.man = man;
          this.ak = ak;
          this.pnr = pnr;

          public boolean equals(Object other) {
          if( other instanceof anmeldungPK ) {
          man.equals(((anmeldungPK)other).man) && ak.equals(((anmeldungPK)other).ak) && pnr.equals(((anmeldungPK)other).pnr)
          return false;

          public int hashCode() {
          man.hashCode() +
          ak.hashCode() +

          public String toString() {

          hope that helps

          • 2. Re: Deploying with Primary Key class
            Marcus Brito Novice

            Take a look at Object.hashCode() javadoc. The short story: hashCode() should return a integer suitable to be used as key in a hash table.