@Override public Portal findById(Portal portal) { EntityManager em = JPAUtil.getEntityManager(); Portal results = new Portal(); try { em.getTransaction().begin(); results = em.find(Portal.class, portal.getPortalId()); em.getTransaction().commit(); } catch (Exception e) { em.getTransaction().rollback(); } finally { em.close(); } return results; }
@Override public void delete(Portal portal) { EntityManager em = JPAUtil.getEntityManager(); try { em.getTransaction().begin(); portal = em.find(Portal.class, portal.getPortalId()); em.remove(portal); em.getTransaction().commit(); } catch (Exception e) { System.out.println(e.getMessage()); em.getTransaction().rollback(); } finally { em.close(); } }