Hi All, I jus took a mock test, A client can determine whether two entity beans are same by comparing their primary key using equals method (true/false) I responded true, but the correct ans was false.
a primary key can be simple string, which may be same for two different beans, but it doesn't mean that the two entity beans are same, it's just an possibility...
If the Pk is same then that means the beans are same. Think about it , you have a database table and two records can't have the same primary key becuase pk is ment to be unique. That means if PK is same then the entity objects are same.
Sawan<br />SCJP,SCWCD,SCBCD<br /> <br />Every exit is an entry somewhere.
The primary key class can be specific to a particular entity bean class.
That is, each entity bean can define its own primary key class. Or multiple entity beans CAN share the same primary key class.
If two entity objects with the SAME home interface have the SAME primary key, they are considered IDENTICAL entity objects. If they have a different primary key, they are considered different entity objects.
There are 2 ways of comparing Entity Beans:
1. Using isIdentical(EJBObject obj) method of javax.ejb.EJBObject interface on bean's REMOTE interface, or isIdentical(EJBLocalObject obj) method of javax.ejb.EJBLocalObject interface on bean's LOCAL interface.
2. Comparing primary keys of two entity object references (ONLY FROM THE SAME HOME INTERFACE !) :