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

Application managed PC does not have scope defined?

 
Ranch Hand
Posts: 1749
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If we use @PersistenceContext to create an entity manager, we can specify the type, either transaction or extended.
But when we use EntityManagerFactory to create the entity manager, I don't see any API that allows us to specify the type.
How to specify the persistence context's type when we use the EntityManagerFactory to create it the entity manager?

Reference: (I don't see any method to specify any pc type in these API)
http://docs.oracle.com/javaee/7/api/javax/persistence/EntityManagerFactory.html
http://docs.oracle.com/javaee/7/api/javax/persistence/PersistenceUtil.html
http://docs.oracle.com/javaee/7/api/javax/persistence/EntityManager.html
 
Creator of Enthuware JWS+ V6
Posts: 3293
296
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An application-managed entity manager always has an extended PersistenceContext.
 
Himai Minh
Ranch Hand
Posts: 1749
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is what the specification says. But for stateful bean, we can have an option between extended scope and transactional scope.

What if we want to have a stateful bean with transactional scope using application managed entity manager?
It seems impossible.
 
Frits Walraven
Creator of Enthuware JWS+ V6
Posts: 3293
296
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

But for stateful bean, we can have an option between extended scope and transactional scope.  


Yes

What if we want to have a stateful bean with transactional scope using application managed entity manager?


That is not possible because an application managed entity manager is injected using

and the @PersistenceUnit annotation doesn't have the type attribute like the @PersistenceContext annotation:
 
Did you just should on me? You should read this tiny ad:
Enterprise-grade Excel API for Java
https://products.aspose.com/cells/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!