// because we keep track of who's the tx owner.
boolean notTxOwner = txm.begin();
Serializable s = generateId(mainObject);
mainObject.setId(Long.valueOf(s.toString()));
cache.put(s, mainObject);
txm.commit(notTxOwner);
// Finish the transaction off
Serializable s2 = generateId(subObject);
subObject.setId(Long.valueOf(s2.toString()));
cache.put(s2, subObject);