• 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
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Bear Bibeault
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • salvin francis
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
Bartenders:
  • Jj Roberts
  • Carey Brown
  • Scott Selikoff

SessionBean doesn't contain unsetEntityContext() ?

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Friends ,,
Will u ppl please tell me why session bean doesnt have unsetEntityContext() .
thanx
 
Ranch Hand
Posts: 2713
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. It is unnecessary for a Session Bean because any clean up code can be placed in the ejbRemove and ejbPassivate methods. ejbRemove is invoked before the end of a Session Bean's lifecycle.
2. A Session Bean doesn't have an EntityContext to unset... .
The reason an EntityBean needs the unsetEntityContext is that ejbRemove may or may not be called before an instance is removed, however unsetEntityContext is always called.
 
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hai,
I would like to why for a session been we have setSessionCintext()method but no but no unsetSessionContext() method.Please explain.
 
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The reason Entity beans have an unsetEntityContext is that the actual instances may be reused. The Entity context contains the Entitity's primary key, thus you have to clear that out before the Entity instance can be returned to the pool.
There is no such primary key used in Session beans. Session Beans are not distinguishable by primary key and are thus not returned to the pool in the same way. Stateful beans aren't pooled to begin with (and so don't need it) and Stateless beans are always considered to be identical at all times, and thus don't need it either.
Kyle
[ November 26, 2002: Message edited by: Kyle Brown ]
 
I'm doing laundry! Look how clean this tiny ad is:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic