• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

2 quick questions...

 
James Turner
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Arun Krishnamoorthy
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 194
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found the answer to the first question:

an IllegalArgumentException would be thrown.

James.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic