Hi everybody ,
I have written a CMP entity bean whose primary key class looks as follows.
There are 2 fields , an int and a String which make up the primary key for
the bean.
public class EmployeeAddressPK implements Serializable
{
public int employee_id;
public String address_type;
public EmployeeAddressPK()
{}
public EmployeeAddressPK(int id , String address_type)
{
this.employee_id = id;
this.address_type = address_type;
}
public int hashCode()
{
System.out.println("EmployeeAddress hashCode() method
called");
StringBuffer sf = new StringBuffer();
sf.append(employee_id);
sf.append(address_type);
return sf.hashCode();
}
public boolean equals(Object primaryKey)
{
if (!(primaryKey instanceof EmployeeAddressPK))
{
return false;
}
else
{
int i = ((EmployeeAddressPK)primaryKey).employee_id;
String addr = ((EmployeeAddressPK)primaryKey).address_type;
return ((this.employee_id == i) &&
(this.address_type.equals(addr)));
}
}
public String toString()
{
return "" + employee_id + "," + address_type;
}
}
When I try to invoke the findByPrimaryKey method on this bean , a strange
thing happens.The hashCode() method is called twice and then surprisingly
the unsetEntityContext() method is called. Now according to what I have read
, unsetEntityContext() method is called by a container ( in my case , it is
Weblogic) when it wants to reduce its pool size. But I dont understand why
it would be happening in this case.It as at this point that I am stuck.
Can somebody explain this behaviour?? And point to some example code
....working code having finders and composite primary keys??
-- Rahul
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".