• 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

Application managed PC does not have scope defined?  RSS feed

 
Ranch Hand
Posts: 1732
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: 3273
296
Android Chrome Eclipse IDE
  • 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: 1732
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: 3273
296
Android Chrome Eclipse IDE
  • 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:
 
Paper jam tastes about as you would expect. Try some on this tiny ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!