This week's giveaway is in the Beginning Java forum.
We're giving away four copies of Bad Programming Practices 101 (e-book) and have Karl Beecher on-line!
See this thread for details.
Win a copy of Bad Programming Practices 101 (e-book) this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

isIdentical understanding  RSS feed

 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because stateless session beans have the same object identity, the isIdentical method always returns true when used to compare them.

I am not able to understand what does same object identity means ?

Please help
 
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For stateless bean, we know all the session bean instances are same which are created in a containere. That is the reason isIdentical() method returns always returns true.

Regards
Kasimurugan R
 
Chetan Sahasrabudhe
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kasimurugan

Thanks for the information.
I guess stateless sesson bean idealy should not have any class attributes.
 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear friends,

On page 141 of the Head First EJB book the author says

the isIdentical() method return TRUE for

stateless beans when they are create from the same HOME,

if you make a new deploy and get another home, the isIdentical

will return false, if compared with the beans created from

the older Home.

The example on the specification use the same home object,

but did not say anything about this.

We can research.... :-)
 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i have tested this...

i created one SLSB and deployed twice with 2 difrent jndi names.Then i created 3 home objects. 2 with from same jndi context and 1 from 2nd jndi context. then i compard(using isIdentical) the ejbObjs from the 1st two.it returnd me true (and it shud). then i campard 1st and 3rd ejbObj(both r deplod with 2 difrent jndi context but of same type). it also returned me true!!!

i also red frm the HFEJB that if u deployed twice , it wil return false.....

something quizzzy....

binoj
 
Binoj Viswanathan
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
also in spec, it says, the container will keep same obj identity for all bean instances from same home type.(P66)
so isIdentical() shud return true even if it deployed twice and using from ejbObj from each one.

binoj
 
Danger, 10,000 volts, very electic .... tiny ad:
Why should you try IntelliJ IDEA ?
https://coderanch.com/wiki/696337/IntelliJ-IDEA
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!