// Commit the mainObject after "commiting" the subObject
EntityManager em = emf.createEntityManager();
try {
// Begin the real trasnaction
boolean txOwner = txm.begin();
// Do the "sub" transaction
// - the txm doesn't really commit,
// because we keep track of who's the tx owner.
boolean notTxOwner = txm.begin();