• 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

Equality test for entity bean

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

any comments..
- Stephen
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
It is true in case of isIdentical(EJBObject o)

Thanks
Siraj
 
Ranch Hand
Posts: 250
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

A client can determine whether two entity beans are same by comparing their primary key using equals method (true/false)



This is true. If the PKs are equal then the two entity beans are same.
 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...
 
sawan parihar
Ranch Hand
Posts: 250
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Praveen Kumar Mathaley
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
dear parihar,
what i meant was two different beans ( i.e two different tables ) can have same primary key.. hope this clears the issue...
 
Bartender
Posts: 3904
43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Howdy !

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 !) :



More details here :
http://java.boot.by/bcd-guide/ch08s02.html

regards,
MZ
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Stephan,

You can conclude the answer is true only if

A client can determine whether two entity beans are same by comparing their primary key using equals method if the entity beans are from same Home

Am I correct ?

means if they includeed the clause "and the entity beans are from same Home " the answer was true.

Best Regards
Thomas
 
This is awkward. I've grown a second evil head. I'm going to need a machete and a tiny ad ...
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic