Friday, December 31, 2010

Java Persistence API Fact Sheet

The following technical details and design issues are random observations about the JPA API and Java in general.  I try to verify through experimentation every fact that appears here - but use this list at your own risk.

DI1: An EntityManager instance is not thread safe @ThreadSafe by design - however a container managed entityManager that is transactional (with default EE PersistenceContextType.TRANSACTION and default EE scoped transaction-type="JTA") is thread safe because you deal directly with a proxy wrapper provided by the enterprise container ($ProxyNN).  The container is able to manage simultaneous access to the referenced EntityManager as well as provide services via bytecode instrumentation/weaving like change tracking, security, resource management and transactions.  Therefore I recommend a container managed entityManager where possible.


Vishy said...
This comment has been removed by the author.
Vishy said...

Is the thread safety (For transaction scoped EntityManager) part of JPA official specification?

PRO JPA 2 book (by Mike Keith and Merrick Schincariol) Does state that They are stateless whereas EJB in Action ( Debu Panda et al) state that They are not thread safe ( at least in injecting in servlets).

Unknown said...

Thanks for this tutorial. It helpful for me.
Máy đo đường huyết giá rẻ

Total Pageviews