Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public List<ItemTablaRegTotalEnt> traerLicenciasExistentesPorEntidad() {
- String consulta = "SELECT e.id_entidad, e.codigo_entidad, e.nombre, sum(t.total) as total ";
- consulta += "FROM total_licencia t, entidad e WHERE e.id_entidad = t.entidad_id ";
- consulta += "GROUP BY e.id_entidad, e.codigo_entidad, e.nombre";
- List<Object> objetos = entityManager.createNativeQuery(consulta).getResultList();
- //------------------------------------------------------------
- //Mapping entrega: id_entidad, codigo_entidad, nombre, total
- //------------------------------------------------------------
- List<ItemTablaRegTotalEnt> items = new ArrayList<ItemTablaRegTotalEnt>();
- for (Object i : objetos) {
- Object[] registro = (Object[]) i;
- ItemTablaRegTotalEnt item = new ItemTablaRegTotalEnt();
- item.setIdEntidad(Integer.parseInt(registro[0] + ""));
- item.setCodigoEntidad(Integer.parseInt(registro[1] + ""));
- item.setNombre((String) registro[2]);
- item.setRegistrosValidos(Integer.parseInt(registro[3] + ""));
- item.setRegistrosInvalidos(0);
- item.setRegistrosTotales(Integer.parseInt(registro[3] + ""));
- items.add(item);
- }
- return items;
- }
Advertisement
Add Comment
Please, Sign In to add comment