Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Passivation Question  RSS feed

 
Bradley Rintoul
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello:

I have a stateful bean which has an EntityManager "injected" into it thusly:

@PersistenceContext(name="myDataSource")
EntityManager em;

My question is this: when my bean is passivated, what happens to its EntityManager?

Do I need to do a JNDI lookup or something on PreActivate? Seems like this should be pretty common, but I have not found anything on it, which makes me think I'm nuts somehow!
 
Edvins Reisons
Ranch Hand
Posts: 364
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The specification covers this, no need to code anything:


If the session bean instance stores in its conversational state an object reference to a container-managed
EntityManager or to an EntityManagerFactory obtained via injection or JNDI lookup, the
container must be able to save and restore the object reference across the instance�s passivation.
 
Bradley Rintoul
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Edvins Reisons:
The specification covers this, no need to code anything:



Excellent! Thanks!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!