public class CanvaService { private CanvaBean dao; private EntityManager em = JPAUtil.getEntityManager(); public CanvaService() { dao = new CanvaBean(em); } public void save(Canva canva) { em.getTransaction().begin(); dao.save(canva); em.getTransaction().commit(); } public void remove(Canva canva) { em.getTransaction().begin(); // dao.delete(canva,canva.); em.getTransaction().commit(); } public Canva find(long pk) { return dao.getById(pk); } public List<Canva> getByName(String name) { return dao.getByName(name); } }
public class ModuleService { private ModuleBean dao; private EntityManager em = JPAUtil.getEntityManager(); public ModuleService() { dao = new ModuleBean(em); } public void save(Module module) { em.getTransaction().begin(); dao.save(module); em.getTransaction().commit(); } public void remove(Module module) { em.getTransaction().begin(); dao.delete(module, module.getIdmodule(), "idModule"); em.getTransaction().commit(); } public Module find(long pk) { return dao.getById(pk); } public List<Module> getByName(String name) { return dao.getByName(name); } }