if (_persistent) {
UserTransaction ut = TransactionManagerLocator.INSTANCE.getUserTransaction();
TransactionManager tm = TransactionManagerLocator.INSTANCE.getTransactionManager();
env.put(EnvironmentName.ENTITY_MANAGER_FACTORY, _entityManagerFactory);
env.put(EnvironmentName.TRANSACTION, ut);
env.put(EnvironmentName.TRANSACTION_MANAGER, new JtaTransactionManager(ut, null, tm));
env.put(EnvironmentName.PERSISTENCE_CONTEXT_MANAGER, new JpaProcessPersistenceContextManager(Environments.getEnvironment(env)));
env.put(EnvironmentName.TASK_PERSISTENCE_CONTEXT_MANAGER, new JPATaskPersistenceContextManager(Environments.getEnvironment(env)));
}
return env;
}