Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Persistence Context Collision explanation in chapter 6

 
Himai Minh
Ranch Hand
Posts: 1361
7
  • 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