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;
  }
 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();
   }
 }
  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;
  }
  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();
    }
  }