Does not order an object with lambda (Java 8)

0

I am making a query of a table as an object to insert it in another table. Sorting with lambda the student_code. I did a proof of concept with two integer values and if it worked, but when I do it with 2 values String does not order them.

public void agregarDatos() {

    AlumnosMaeBean prueba = new AlumnosMaeBean();
    List<SisAlumnosMae> alumnoMaeList = prueba.consultaTodoMae();

    /*Ordenamos la lista por codigo alumno*/

    alumnoMaeList.sort((SisAlumnosMae h1, SisAlumnosMae h2) -> Integer.parseInt(h1.getCodigoAlumno()) - Integer.parseInt(h2.getCodigoAlumno()));

    /*agregamos a la tabla Sis_Alumnos_idx*/
    try {
        for (SisAlumnosMae mae : alumnoMaeList) {
            SisAlumnosIdx alumnoIdx = new SisAlumnosIdx();
            admin.getTransaction().begin();
            alumnoIdx.setCodigoAlumno(mae.getCodigoAlumno());
            alumnoIdx.setNombre(mae.getNombre());
            alumnoIdx.setApellido(mae.getApellido());
            alumnoIdx.setEdad(mae.getEdad());
            alumnoIdx.setSemestre(mae.getSemestre());
            alumnoIdx.setSexo(mae.getSexo());
            alumnoIdx.setEstadoAlumno(mae.getEstadoAlumno());
            alumnoIdx.setSecuenciaAlumno(mae.getSecuenciaAlumno());
            admin.persist(alumnoIdx);
            admin.merge(alumnoIdx);
            admin.getTransaction().commit();

        }

    } catch (Exception e) {
        e.printStackTrace();
    }

}
    
asked by José T. 21.03.2018 в 01:52
source

0 answers