what to write the code in equals method in primary class

Discussions

EJB design: what to write the code in equals method in primary class

  1. hello everybody,

    1)what to write the code in equals method in primary class for the compound primary key i.e

    class primary
    {
    public String str1;
    public String str2;

    public boolean equals(Object o)
    {
    }

    }

    2) what are the situations in which we choose the appropraite way to make the method session/entity/calling entity from session to make database interaction

    with regards
    k.ramakrishna
    kalavendi@yahoo.com
  2. Hi Ramakrishna,

    Answer for Question (1):

    public boolean equals(Object other) {
        if (other instanceof primary) {
            return (str1.equals(((primary)other).str1)
                && (str2.equals(((primary)other).str2));
        }
    }

    ----------------------
    The answer for ur second question is already send to u by mail.

    thanks...hasan
    (ahamed at aztec dot soft dot net)