3 Replies Latest reply on Aug 27, 2001 1:25 PM by praveen

    An error when deploying EJB.. is this a bug.

      Hi all,

      I am trying to deploy a BMP EJB.

      I am getting this following exception.


      Section: 9.2.9
      Warning: The primary key class must override equals().


      I have implemented the equals method in my PK class..

      And here the implementation code..

      public boolean equals(MyBMPPK other) {
       return ( this.MY_ID.equals(other.MY_ID)
       && this.MY_ID2.equals(other.MY_ID2) );
      
      }
      


      I appreciate any help in fixing this problem.


        • 1. Re: An error when deploying EJB.. is this a bug.
          seven

          Try to do it like this:

          public boolean equals(Object other){
          if(other instanceof MyBMPPK){
          MyBMPPK otherpk = (MyBMPPK)other;
          if(otherpk.MY_ID.equals(this.MY_ID) && otherpk.MY_ID2.equals(this.MY_ID2))
          return true;
          else return false;
          }
          return false;
          }

          In fact u didn't override the equals method 'cause the signature is
          public boolean equals(Object other) and u used
          public boolean equals(MyBMPPK other)

          • 2. Re: An error when deploying EJB.. is this a bug.

            I think your problem is that you've overloaded the equals method, not overridden it.

            It should be declared as:

            public boolean equals(Object other)
            {
             if(other instanceof MyBMPPK)
             return ( this.MY_ID.equals(((MyBMPPK)other).MY_ID)
             && this.MY_ID2.equals(((MyBMPPK)other).MY_ID2) );
             else
             return false;
            }
            

            Note the argument to the method.

            Hope this helps,
            Dan Ciarniello



            • 3. Re: An error when deploying EJB.. is this a bug.

              Thanks for your help, Dan & "Seven".