Hi, I would like to know under what circumstances its possible for 2 entity beans EJB object references to return different results for the getPrimaryKey() and isIdentical() tests? For example, considering the following is it possible to have only 1 of the 2 System.out's being printed? CustomerLocal cust1 = ...; CustomerLocal cust2 = ...; if ( cust1.getPrimaryKey().equals(cust2.getPrimaryKey()) { System.out.println("pk eqs"); } if ( cust1.isIdentical(cust2) ) { System.out.println("isIdentical eqs"); }
I've looked in the spec and couldnt find what I thought was a definitive answer to this? thanks, Dean
shadow liu
Ranch Hand
Joined: Mar 19, 2001
Posts: 33
posted
0
As spec says: (P120) --------- A client can test whether two entity object references refer to the same entity object by using the isIdentical method. Alternatively, if a client obtains two entity object references from the same home, it can determine if they refer to the same entity by comparing their primary keys using the equals method. ------------ So, if the two reference is from same home, then these two method should always return same result. Else, like two different entity bean class, they can have same string as their primary key, but they are not identical. HTH. Shadow.