The various partial descriptions of the subject have led me to suspect that BMT is strongly tied to an application-managed EntityManager (and the use of UserTransaction), and that CMT is strongly tied to a container-managed EntityManager.
Can anyone give (or point me to) a clear explanation of how exactly BMT/CMT relates to an application/container-managed EntityManager?
What combinations are allowed between transaction demarcation types and EntityManager management types?
- Can I combine an application-managed EntityManager with CMT?
- Can I combine a container-managed EntityManager with BMT?
Also, what is the relationship between UserTransaction and BMT/CMT vs application/container-managed EntityManager?
- Can I use UserTransaction together with a container-managed EntityManager?
- Does UserTransaction imply BMT and vice-versa?
EDIT: According to http://www.byteslounge.com/tutorials/container-vs-application-managed-entitymanager I can combine CMT/BMT with application/container-managed EntityManagers any way I like. That still leaves me with the question about the relationship between UserTransaction and BMT. Does one imply the other?
EDIT: contrary to the link posted above, http://docs.oracle.com/javaee/6/tutorial/doc/bnbqw.html#bnbra claims that "Application-managed entity managers don’t automatically propagate the JTA transaction context. Such applications need to manually gain access to the JTA transaction manager and add transaction demarcation information when performing entity operations. The javax.transaction.UserTransaction interface defines methods to begin, commit, and roll back transactions. Inject an instance of UserTransaction by creating an instance variable annotated with @Resource". To me this sounds like "application-managed entity managers require bean managed transaction demarcations". Who is right? Oracle or Byteslounge?