+
+ @Override
+ public TransactionResult rollback(EntityManager aEntityManager) {
+ try {
+ EntityTransaction transaction = aEntityManager.getTransaction();
+ if (transaction.isActive()) {
+ transaction.rollback();
+ return TransactionResult.ROLLBACK;
+ }
+ return TransactionResult.UNKNOWN;
+ } finally {
+ if (aEntityManager.isOpen()) {
+ aEntityManager.close();
+ }
+ entityManager.set(null);
+ }
+ }
+
+ /**
+ * Gets a contextual reference to an entity manager that delegates to the
+ * appropriate (current) one which is active for the current transaction.
+ *
+ * @return EntityManager.
+ */
+ public EntityManager getContextualEntityManager() {
+ return entityManager.getProxy();
+ }