Win a copy of Event Streams in Action this week in the Java in General 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
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Persistence Context Collision explanation in chapter 6

 
Ranch Hand
Posts: 1742
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:

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