This week's book giveaway is in the HTML Pages with CSS and JavaScript forum.
We're giving away four copies of React Cookbook: Recipes for Mastering the React Framework and have David Griffiths & Dawn Griffiths on-line!
See this thread for details.
Win a copy of React Cookbook: Recipes for Mastering the React Framework this week in the HTML Pages with CSS and JavaScript 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

Persistence Context Collision explanation in chapter 6

 
Bartender
Posts: 2113
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:

 
We find this kind of rampant individuality very disturbing. But not this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic