I\'ve got a DAO that I used to load and save my domain objects using JPA. I finally managed to get the transaction stuff working, now I\'ve got another issue.
In my
Here is what I used (based on the previous answers)
public void deleteTask(int taskId) {
Task task = getTask(taskId); //this is a function that returns a task by id
if (task == null) {
return;
}
EntityManager em = emf.createEntityManager();
EntityTransaction et = em.getTransaction();
et.begin();
em.remove(em.merge(task));
et.commit();
em.close();
}