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

Equality test for entity bean

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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: 3645
38
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
I am Arthur, King of the Britons. And this is a tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic