aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Object equality for Session beans Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Object equality for Session beans" Watch "Object equality for Session beans" New topic
Author

Object equality for Session beans

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9351
    
    2

The below lines are from the EJB 3 Spces!

3.4.5.1 Stateful Session Beans
A stateful session object has a unique identity that is assigned by the container at the time the object is
created. A client of the stateful session bean business interface can determine if two business interface
references refer to the same session object by use of the equals method.
For example,
@EJB Cart cart1;
@EJB Cart cart2;
...
if (cart1.equals(cart1)) { // this test must return true
...
}
...
if (cart1.equals(cart2)) { // this test must return false
...
}
All stateful session bean references to the same business interface for the same stateful session bean
instance will be equal. Stateful session bean references to different interface types or to different session
bean instances will not have the same identity.


Does this hold good for Stateless beans as well?


SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9351
    
    2

Just read the next lines from the specs,

3.4.5.2 Stateless Session Beans
All business object references of the same interface type for the same stateless session bean have the
same object identity, which is assigned by the container.
For example,
@EJB Cart cart1;
@EJB Cart cart2;
...
if (cart1.equals(cart1)) { // this test must return true
...
}
...
if (cart1.equals(cart2)) { // this test must also return true
...
}
The equals method always returns true when used to compare references to the same business interface
type of the same session bean. Session bean references to either different business interface types
or different session beans will not be equal.


Got my doubt clarified!

The specs are awesome and now I find that they are a must read for the SCBCD 5!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Object equality for Session beans