public void delete(EntityManager em, DeviceHistory deviceHistory) { em.detach(this); long journalId = Sequence.generateId(em); TransactionJournal journalEntry = new TransactionJournal( journalId, deviceHistory, TransactionType.DELETE, new Instant(), getTransactionId(), getChildId(), getDescription(), getDate(), getAmount()); em.persist(journalEntry); }
public long persist(EntityManager em, DeviceHistory deviceHistory) { em.persist(this); long journalId = Sequence.generateId(em); TransactionJournal journalEntry = new TransactionJournal( journalId, deviceHistory, TransactionType.CREATE, new Instant(), getTransactionId(), getChildId(), getDescription(), getDate(), getAmount()); em.persist(journalEntry); em.flush(); return journalEntry.getJournalId(); }