Esempio n. 1
0
  @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;
  }
Esempio n. 2
0
  @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();
    }
  }