@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(); } }
@Override public Portal findByPortalNumber(Portal portal) { EntityManager em = JPAUtil.getEntityManager(); Portal results = new Portal(); try { em.getTransaction().begin(); results = (Portal) em.createNamedQuery("findByPortalNumber") .setParameter("portalNumber", portal.getPortalNumber()) .getSingleResult(); em.getTransaction().commit(); } catch (Exception e) { em.getTransaction().rollback(); } finally { em.close(); } return results; }