@Override public void persistFinancialSource(FinancialSource source) { EntityManager entityManager = this.getSession().getEntityManager(); TransactionScope transactionScope = this.beginTransaction(); try { entityManager.persist(source); markAsChanged(source); transactionScope.commit(); } finally { transactionScope.dispose(); } }
@Override public void persistPayment(Payment payment) { if (payment == null) throw new IllegalArgumentException("Argument 'payment' must not be null."); EntityManager entityManager = this.getSession().getEntityManager(); TransactionScope transactionScope = this.beginTransaction(); try { entityManager.persist(payment); markAsChanged(payment); transactionScope.commit(); } finally { transactionScope.dispose(); } }
@Override public void deleteFinancialSource(int id) { EntityManager entityManager = this.getSession().getEntityManager(); TransactionScope transactionScope = this.beginTransaction(); try { entityManager .createQuery("DELETE FROM FinancialSource fs WHERE fs.id :finId") .setParameter("finId", id) .executeUpdate(); transactionScope.commit(); } catch (PersistenceException ex) { throw TransactionHelper.translateException(ex); } finally { transactionScope.dispose(); } }