• 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
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Persistence Context Collision explanation in chapter 6  RSS feed

 
Ranch Hand
Posts: 1732
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
In chapter 6 of JPA Pro2, it talks about persistence context collision.
When a stateless bean in transaction scoped persistence context (PC 1 ) is running, it cannot invoke a stateful bean's extended scoped PC 2.
PC2 is eager , which means it is created when the stateful bean is initialized.
PC1 is lazy, which means it is created when the stateless bean runs its method.
Error message :javax.ejb.EJBException: There is an active transactional persistence context for the same EntityManagerFactory as the current stateful session bean's extended persistence context
PC1 cannot run inside PC2 as PC2 has been created first.
Why?

But we can do it the other way round as demo in extendedPersistenceContext example.
A stateful bean in extended scope PC 2 can invoke a stateless bean in transaction scope PC 1.
PC1 can be run inside PC2 in this case.
Why?
FYI:

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!