-
1. Re: java.lang.IllegalStateException: removing bean lock and
adrian.brock Jun 24, 2003 5:09 AM (in response to saddysan)The most likely cause of this problem is that
you a bad primary key implementation
hashCode, equals or serialization.
Regards,
Adrian -
2. Re: java.lang.IllegalStateException: removing bean lock and
saddysan Jun 24, 2003 6:48 AM (in response to saddysan)I think u r right, even at the time of deployment serevr warned about this(that there is no proper implementation of hashCode and equals method)
but however i think i have implemented these methods correctly, may be u can help ime n finding the error. here is the code for my Primary Key class
package account;
import java.io.Serializable;
/**
* Primary Key class for Account.
*/
public class AccountPK extends Object implements java.io.Serializable {
public String accountID;
public AccountPK(String id) {
this.accountID = id;
}
public AccountPK() {
}
public String toString() {
return accountID;
}
public int hashCode()
{
return super.hashCode();
}
public boolean equals(Object obj)
{
return super.equals(obj);
}
} -
3. Re: java.lang.IllegalStateException: removing bean lock and
adrian.brock Jun 24, 2003 7:34 AM (in response to saddysan)No that is not correct.
public int hashCode()
{
return id.hashCode();
}
public boolean equals(Object obj)
{
if (obj == this) return true; // quick check
if (obj == null) return false; // null is never equal
if ((obj instanceof AccountPK) return false); // wrong type
AccountPK other = (AccountPK) obj;
return obj.id.equals(other.id); // Check the ids
}
You want to primary keys to be the same if they
have the same id, not if they are the same
object instance which has how "super"
(java.lang.Object) implements them.
Regards,
Adrian -
4. Re: java.lang.IllegalStateException: removing bean lock and
saddysan Jun 25, 2003 12:59 AM (in response to saddysan)thanx,
its working now