Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

getPrimaryKey() vs isIdentical()

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Nothing? Or something? Like this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic