aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes 2 quick questions... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "2 quick questions..." Watch "2 quick questions..." New topic
Author

2 quick questions...

James Turner
Ranch Hand

Joined: May 10, 2004
Posts: 194
Hi Guys,

I have two quick questions:

1. In an entity bean's one to many releationship, say for example ParentEntity and ChildEntity (ParentEntity is on the one side, ChildEntity is on the many side), what would happen if the ParentEntity.setChildEntityCollection(null); was called? Would this be allowed or throw an EJBException?

2. Why do entity beans have unsetEntityContext method and session beans don't have unsetSessionContext? Is there any reason entities need this and sessions don't? It would happen at the same point in both lifecycles.

Thank you for your time.

Regards,

James.


James<br />SCJP 1.4 - 92%<br />SCJD - 93%<br />SCWCD 1.4 - 95%<br />SCBCD 1.3 - 100%<br />SCEA - 92%
Arun Krishnamoorthy
Greenhorn

Joined: Nov 03, 2004
Posts: 22
Session Beans do not need an unsetSessionContext() since an ejbRemove() callback can be used to handle all clean-up code needed when moving from "ready" to "does not exist" state. For an entity bean, ejbRemove() causes the entity bean to go back to the pool only (the entity bean instance still exists in the jvm heap). If the pool size becomes too large, the container would still need to move this entity bean instance to the "does not exist state". Since the ejbRemove() callback CANNOT be used for the reason mentioned above, unsetEntityContext() callback was provided.

Session beans have no such need since ejbRemove() itself can handle the state transition.
James Turner
Ranch Hand

Joined: May 10, 2004
Posts: 194
I found the answer to the first question:

an IllegalArgumentException would be thrown.

James.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: 2 quick questions...