• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Calling isIdentical on two entity beans

 
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Everyone,
This is one of the mock exam questions. Please go through the code..

A session bean is executing the methods of two entity beans. While executing isIdentical() of two entity beans is showing that they are same even though they are not, then how can you determine that they are not identical?

1. compare their equals method in the Primary key class
2. compare their hashcode method in the Primary key class
3. find out the getPrimaryKey method from their respective entity bean class
4. find out from the getHandle method from their respective entity bean class
Select Two options:

What might be the correct answer to this question.
Thanks in Advance
 
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is good chance that the primary key classes of the beans are messed up. So I choose options 1 and 2. I'm counting on my container to return correct primary keys and handles. So I trust that the getPrimaryKey() and getHandle() methods work perfectly

I'm sincerely hoping that the real exam does not have these type of questions.
 
Ranch Hand
Posts: 389
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

This is what the specs have to say about this:

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


Further Enterprise JavaBeans architecture does not specify �object equality� (i.e. use of the ==
operator) for entity object references. The result of comparing two object references using the Java programming
language Object.equals(Object obj) method is unspecified. Performing the
Object.hashCode() method on two object references that represent the entity object is not guaranteed
to yield the same result.

As per me (1) and (3) are the correct answers so you retrieve the primary keys for the entity beans and compare the primary keys using equals method.

Thanks

Ravi
[ March 01, 2005: Message edited by: Ravindra Janapareddy ]
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic