コード例 #1
0
  public List<AvanceArrendatario> obtenerTodos() throws Exception {

    List<AvanceArrendatario> datos = new ArrayList<AvanceArrendatario>();
    Session em = sesionPostgres.openSession();
    try {
      datos = (List<AvanceArrendatario>) em.createCriteria(AvanceArrendatario.class).list();
    } catch (Exception e) {

      throw new Exception(e.getMessage(), e.getCause());
    } finally {
      em.close();
    }

    return datos;
  }
コード例 #2
0
 public void actualizarAvance(int posi, AvanceArrendatario dato) throws Exception {
   @SuppressWarnings("static-access")
   Session em = sesionPostgres.openSession();
   Transaction tx = null;
   try {
     tx = em.beginTransaction();
     em.update(dato);
     tx.commit();
   } catch (Exception e) {
     tx.rollback();
     e.printStackTrace();
     throw e;
   } finally {
     em.close();
   }
 }
コード例 #3
0
  public AvanceArrendatario obtenerAvance(int id) throws Exception {
    @SuppressWarnings("static-access")
    Session sesion = sesionPostgres.openSession();
    AvanceArrendatario dato = null;
    try {
      dato = (AvanceArrendatario) sesion.get(AvanceArrendatario.class, id);
    } catch (Exception e) {
      e.printStackTrace();

      throw new Exception(e.getMessage(), e.getCause());
    } finally {
      sesion.close();
    }

    return dato;
  }
コード例 #4
0
  public void eliminarAvance(int posi, AvanceArrendatario dato) throws Exception {
    @SuppressWarnings("static-access")
    Session sesion = sesionPostgres.openSession();
    Transaction tx = null;
    try {
      tx = sesion.beginTransaction();
      sesion.delete(dato);
      tx.commit();

    } catch (Exception e) {
      tx.rollback();

      throw new Exception(e.getMessage(), e.getCause());
    } finally {
      sesion.close();
    }
  }