• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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 ]
 
Anderson gave himself the promotion. So I gave myself this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic