Win a copy of AWS Security this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

2 quick questions...

 
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.
 
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.
 
Everybody! Do the Funky Monkey! Like this tiny ad!
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic