// use local uow as it will be local to this EM and not on the txn
if (this.extendedPersistenceContext == null || !this.extendedPersistenceContext.isActive()) {
if(this.connectionPolicy == null) {
createConnectionPolicy();
}
ClientSession client = this.serverSession.acquireClientSession(connectionPolicy, properties);
this.extendedPersistenceContext = new RepeatableWriteUnitOfWork(client, this.referenceMode);
this.extendedPersistenceContext.setResumeUnitOfWorkOnTransactionCompletion(!this.closeOnCommit);
this.extendedPersistenceContext.setShouldDiscoverNewObjects(this.persistOnCommit);
this.extendedPersistenceContext.setDiscoverUnregisteredNewObjectsWithoutPersist(this.commitWithoutPersistRules);
this.extendedPersistenceContext.setFlushClearCache(this.flushClearCache);
this.extendedPersistenceContext.setShouldValidateExistence(this.shouldValidateExistence);
this.extendedPersistenceContext.setShouldOrderUpdates(this.shouldOrderUpdates);
this.extendedPersistenceContext.setShouldCascadeCloneToJoinedRelationship(true);
this.extendedPersistenceContext.setShouldStoreByPassCache(this.cacheStoreBypass);
if (txn != null) {
// if there is an active txn we must register with it on
// creation of PC
transaction.registerUnitOfWorkWithTxn(this.extendedPersistenceContext);
}
if (client.shouldLog(SessionLog.FINER, SessionLog.TRANSACTION)) {
client.log(SessionLog.FINER, SessionLog.TRANSACTION, "acquire_unit_of_work_with_argument", String.valueOf(System.identityHashCode(this.extendedPersistenceContext)));
}
}
if (this.beginEarlyTransaction && txn != null && !this.extendedPersistenceContext.isInTransaction()) {
// gf3334, force persistence context early transaction
this.extendedPersistenceContext.beginEarlyTransaction();