public ArrayList
ArrayList
ArrayList
int idpersona=Integer.parseInt(id);
ArrayList
ArqueoCaja ac;
try {
Session sesion = HibernateUtil.getSessionFactory().getCurrentSession();
sesion.beginTransaction();
Query q = sesion.createSQLQuery("select p.nombre, p.apellido, sum(m.valor), monthname(m.fecha), year(m.fecha) from persona p, movimiento m where p.id_persona=m.fk_id_persona and p.id_persona="+idpersona+" and m.tipo='Ingreso' group by(p.nombre), monthname(m.fecha), year(m.fecha)");
Query p = sesion.createSQLQuery("select p.nombre, p.apellido, sum(m.valor), monthname(m.fecha), year(m.fecha) from persona p, movimiento m where p.id_persona=m.fk_id_persona and p.id_persona="+idpersona+" and m.tipo='Egreso' group by(p.nombre), monthname(m.fecha), year(m.fecha)");
bIngresos = (ArrayList
bEgresos = (ArrayList
Iterator iti=bIngresos.iterator();
Iterator ite=bEgresos.iterator();
while (iti.hasNext()) {
while(ite.hasNext()){
Object[] resulti=(Object[])iti.next();
Object[] resulte=(Object[])ite.next();
ac=new ArqueoCaja();
ac.setNombre((String) resulti[0]);
ac.setApellido((String) resulti[1]);
ac.setTotalIngreso((Double) resulti[2]);
ac.setTotalEgreso((Double) resulte[2]);
ac.setDiferencia((Double)resulti[2]-(Double)resulte[2]);
ac.setMes((String) resulti[3]);
ac.setAnio((Integer) resulti[4]);
nueva.add(ac);
}
}
} catch (Exception e) {
e.printStackTrace();
}
return nueva;
}
No hay comentarios:
Publicar un comentario