Forums Register Login
isIdentical understanding
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
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.

Kasimurugan R

Thanks for the information.
I guess stateless sesson bean idealy should not have any class attributes.
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.... :-)
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....

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.


This thread has been viewed 610 times.

All times above are in ranch (not your local) time.
The current ranch time is
Oct 15, 2018 16:05:29.