Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Entity Bean - ejbPassivate()

 
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Reference: EJB Spec 2.0 Final Release
Page: 169
Container can choose to passivate an entity bean instance with in a transaction


Reference: Head First EJB
Page: 311
Under EntityBean interface
ejbPassivate() called when the bean is about to return to the pool, following a transaction
Are'nt these two sentences contradictory? If they are not can someone explain what do they exactly mean?
[ April 15, 2004: Message edited by: Santosh Ram ]
[ April 15, 2004: Message edited by: Santosh Ram ]
 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I think you are getting slightly confused.
For a stateful *session* bean, you are correct - it will not be passivated whilst in a tx.
For an Entity bean, it may be passivated by the container whilst that Entity bean is participating within a tx.
That is what the spec is alluding to.
-=david=-
 
Santosh Ramachandrula
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi David,
Thanks for the reponse. I understood what you said. In my question the two statements from two different books and are referening to EntityBean...so I feel that they are contradictory??


Reference: EJB Spec 2.0 Final Release
Page: 169
Container can choose to passivate an entity bean instance with in a transaction
Reference: Head First EJB by Kathy, Bates
Page: 311
Under EntityBean interface
ejbPassivate() called when the bean is about to return to the pool, following a transaction
[ April 16, 2004: Message edited by: Santosh Ram ]
 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Santosh,
I had the same doubt when I was reading the spec. But then I thought about it and this is what I concluded:
The spec says
Container can choose to passivate an entity bean instance with in a transaction
and it also mentions that

To passivate
an instance, the container first invokes the ejbStore method to allow the instance to prepare
itself for the synchronization of the database state with the instance�s state, and then the container
invokes the ejbPassivate method to return the instance to the pooled state.
on page 169 and on page 172 it mentions that ejbPassivate() runs in an unspecified transaction context.
So, I think contains can choose to passivate the bean does not mean that it is calling ejbPassivate() there, it means it is getting ready to passivate and since ejbStore runs in a transaction, it calls ejbStore first and I believe the transaction ends there and then it calls ejbPassivate() in an unspecified transaction context.
I hope this helps and that I haven't confused you even more.
 
Santosh Ramachandrula
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sany Thanks!! You made it clear to me, it was a good explanation.
Santosh
 
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Santosh Ram:
Sany Thanks!! You made it clear to me, it was a good explanation.
Santosh


Yeah, Sany's explanation is great!!!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic