Recall from the previous lesson that the relationship between clients and entity beans is many-to-one.
Many clients can access the same entity bean. This is illustrated in the following diagram:
In the diagram there is one instance and one client.
However, the client has two references to the same instance.
This situation may have arisen by one reference being a return from a create() method and the other from a findByPrimaryKey() method.
The question the client program may need to know is: "Do both references refer to the same instance or not?"
isIdentical()
The EJBObject provides the isIdentical() method for entity beans in the same way it does for session beans.
This method can be used to compare the identities of the beans that have references in your client program. The rule is that references to entity bean instances that refer to the same instance will compare equal when you use
isIdentical(). View the diagram below to examine the following client code.
Click the Quiz link below to test your understanding of the entity bean client. Entity Bean Client - Quiz
The next lesson introduces the complete code for the Customer client.