urgent bean managed example fo edroman ejbc error

Discussions

EJB programming & troubleshooting: urgent bean managed example fo edroman ejbc error

  1. urgent bean managed example fo edroman ejbc error (3 messages)

    hai

    I am trying to deploy bean managed entity bean example given in ed roman book.chapter 8.
    I am using weblogic ver5.1.

    in my descriptor i have given primary class as AccountPK

    ejdc gives me an error stating that i should implement pulic boolean equals(object o) and public int hashCode()
    method .

    please tell me ho should I proceed?

    uregent.

    banking on your help.

    vaidya


    a copy of error
    ERROR: Error from ejbc: [9.2.9] In EJB romanbm, the primary key class must imple
    ment the method boolean equals(Object other).
    ERROR: Error from ejbc: [9.2.9] In EJB romanbm, the primary key class must imple
    ment the method public int hashCode().
    ERROR: ejbc found errors

    Threaded Messages (3)

  2. add the follwing methods to ur pk class. the pk class i presume may have some variable called accountID.


    public int hashCode() {
    return ((accountID).hashCode());
    }

    public boolean equals(Object obj){
    if(!(obj instanceof AccountPK))
      return false;
    if( (accountID.equals(((AccountPK)obj).getAccountID())) )
    return true;
    else
    return false;
    }
  3. URGENT - ejbc error ...[ Go to top ]

    Hi !
    I use weblogic 5.1. I've created jar file manually. But when I try to generate container classes using ejbc, I get the following error:
    ERROR: Error from ejbc: [9.2.9] In EJB Test, the primary key class must implement the method public int hachCode()

    ERROR: Error from ejbc: [9.2.9] In EJB Test, the primary key class must implement the method boolean equals <Object other>.
    ERROR: ejbc found errors.

    Then I included the two methods in my Primary class files ()returning 0 and false). But still I get the same errors.
    Could any one help me out regarding this problem. It is very urgent. This is my primary key class :

    package hitachi.buyplan;
    import java.io.Serializable;
    public class TestPK implements Serializable
    {
        public TestPK(){}

        public int hashCode()
        {
            return 0;
        }
        public boolean equals(Object obj)
        {
                return false;
        }
    }



    Thanx
    AJP
  4. URGENT - ejbc error ...[ Go to top ]

    Hi,

    Make u'r code as follows:
    public class TestPK implements Serializable
    {
        public TestPK(){}
        public int id;
        public int hashCode()
        {
            return id;
        }
        public boolean equals(Object obj)
        {
            if(obj instanceof TestPK)
            {
                return (id == ((TestPK)obj).id);
            }
            return false;
        }
        public String toString()
        {
           return String.valueOf(id);
        }

    }

    Hope now it will work

    Regards
    Saran