Questions regarding EntityManagers/Persistence Contexts in a multi-threaded
stand-alone app

We have a Swing app and we want to use JPA to display/modify data backed by
the database.  The GUI will occasionally spawn a thread (or threads) to
perform network protocols which may in turn update the database.

- Based on the fact that we are a standalone app (no container), we use
Application-Managed Entity Managers (we control the lifecycle of the
EntityManagers)

- This indicates that our EntityManager(s) will have Extended Persistence
Context



Here are our questions:

- Since the GUI itself will be a single thread, do we use a single
EntityManager for the GUI, and allow the PersistenceContext to exist for the
lifetime of the application?

- Does each network protocol thread create its own
EntityManager/PersistenceContext?  Or, do we use OpenJPA's multi-threaded
feature and share the GUI's PersistenceContext?

- If the network protocol threads use individual PCs, how do we reliably
ensure that the GUI's PC sees the changes?

- Since we are using an Entity Manager with Extended Persistence Context,
this has implications for transactions.  Is everything within a single
PersistenceContext part of an implicit transaction, even if an Entity is
modified outside of an explicit transaction.begin?


I've been researching the PersistenceContext issue for a while now, but it
seems like most of the OpenJPA answers focus on container-based apps, so I'm
stuck.


Thanks for any help
I'm sure I'll have follow-up questions :)

ktj
-- 
View this message in context: 
http://www.nabble.com/Extended-Persistence-Context-in-multi-threaded-app-tp15160167p15160167.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Reply via email to