Example usage for org.hibernate Session doWork

List of usage examples for org.hibernate Session doWork

Introduction

In this page you can find the example usage for org.hibernate Session doWork.

Prototype

void doWork(Work work) throws HibernateException;

Source Link

Document

Controller for allowing users to perform JDBC related work using the Connection managed by this Session.

Usage

From source file:com.mimp.hibernate.HiberReporte.java

public ArrayList<EstudioCaso> getEstudioCasoMensual(Long idNna) {
    Session session = sessionFactory.getCurrentSession();
    session.beginTransaction();/*  www . j a  v  a 2s .co m*/

    final Long idN = idNna;
    final ArrayList<EstudioCaso> listaEstudio = new ArrayList();
    Work work = new Work() {
        @Override
        public void execute(Connection connection) throws SQLException {

            String hql = "{call REPORTE_ESTUDIO_MENSUAL(?,?)}";
            CallableStatement statement = connection.prepareCall(hql);
            statement.setLong(1, idN);
            statement.registerOutParameter(2, OracleTypes.CURSOR);
            statement.execute();

            ResultSet rs = (ResultSet) statement.getObject(2);

            while (rs.next()) {
                EstudioCaso tempEst = new EstudioCaso();
                ExpedienteFamilia tempEF = new ExpedienteFamilia();
                Familia tempFam = new Familia();
                Entidad tempEnt = new Entidad();

                tempEF.setIdexpedienteFamilia(rs.getLong("IDEXPEDIENTE_FAMILIA"));
                tempEF.setExpediente(rs.getString("EXPEDIENTE"));
                tempEF.setNacionalidad(rs.getString("NACIONALIDAD"));

                tempFam.setIdfamilia(rs.getLong("IDFAMILIA"));
                Long idEntidad = rs.getLong("IDENTIDAD");
                if (!rs.wasNull()) {
                    String query2 = "{call RENAD_ENTIDAD(?,?)}";
                    CallableStatement statement2 = connection.prepareCall(query2);
                    statement2.setLong(1, idEntidad);
                    statement2.registerOutParameter(2, OracleTypes.CURSOR);
                    statement2.execute();
                    ResultSet rs2 = (ResultSet) statement2.getObject(2);
                    while (rs2.next()) {
                        tempEnt.setIdentidad(rs2.getLong("IDENTIDAD"));
                        tempEnt.setNombre(rs2.getString("NOMBRE"));
                        tempEnt.setUser(rs2.getString("USER_"));
                        tempEnt.setPass(rs2.getString("PASS"));
                        tempEnt.setDireccion(rs2.getString("DIRECCION"));
                        tempEnt.setTelefono(rs2.getString("TELEFONO"));
                        tempEnt.setPais(rs2.getString("PAIS"));
                        tempEnt.setResolAuto(rs2.getString("RESOL_AUTO"));
                        tempEnt.setFechaResol(rs2.getDate("FECHA_RESOL"));
                        tempEnt.setResolRenov(rs2.getString("RESOL_RENOV"));
                        tempEnt.setFechaRenov(rs2.getDate("FECHA_RENOV"));
                        tempEnt.setFechaVenc(rs2.getDate("FECHA_VENC"));
                        tempEnt.setObs(rs2.getString("OBS"));
                    }
                    rs2.close();
                    statement2.close();
                    tempFam.setEntidad(tempEnt);
                }
                tempEF.setFamilia(tempFam);
                tempEst.setExpedienteFamilia(tempEF);
                tempEst.setResultado(rs.getString("RESULTADO"));
                tempEst.setPrioridad(rs.getLong("PRIORIDAD"));
                tempEst.setFechaEstudio(rs.getDate("FECHA_ESTUDIO"));
                tempEst.setFechaSolAdop(rs.getDate("FECHA_SOL_ADOP"));
                listaEstudio.add(tempEst);
            }
            rs.close();
            statement.close();
        }
    };
    session.doWork(work);

    return listaEstudio;
}

From source file:com.mimp.hibernate.HiberReporte.java

public ArrayList<EstudioCaso> getEstudioCasoHistorico(Long idNna) {
    Session session = sessionFactory.getCurrentSession();
    session.beginTransaction();/*ww w.jav a 2  s  .  c o m*/

    final Long idN = idNna;
    final ArrayList<EstudioCaso> listaEstudio = new ArrayList();
    Work work = new Work() {
        @Override
        public void execute(Connection connection) throws SQLException {

            String hql = "{call REPORTE_ESTUDIO_HISTORICO(?,?)}";
            CallableStatement statement = connection.prepareCall(hql);
            statement.setLong(1, idN);
            statement.registerOutParameter(2, OracleTypes.CURSOR);
            statement.execute();

            ResultSet rs = (ResultSet) statement.getObject(2);

            while (rs.next()) {
                EstudioCaso tempEst = new EstudioCaso();
                ExpedienteFamilia tempEF = new ExpedienteFamilia();
                Familia tempFam = new Familia();
                Entidad tempEnt = new Entidad();

                tempEF.setIdexpedienteFamilia(rs.getLong("IDEXPEDIENTE_FAMILIA"));
                tempEF.setExpediente(rs.getString("EXPEDIENTE"));
                tempEF.setNacionalidad(rs.getString("NACIONALIDAD"));

                tempFam.setIdfamilia(rs.getLong("IDFAMILIA"));
                Long idEntidad = rs.getLong("IDENTIDAD");
                if (!rs.wasNull()) {
                    String query2 = "{call RENAD_ENTIDAD(?,?)}";
                    CallableStatement statement2 = connection.prepareCall(query2);
                    statement2.setLong(1, idEntidad);
                    statement2.registerOutParameter(2, OracleTypes.CURSOR);
                    statement2.execute();
                    ResultSet rs2 = (ResultSet) statement2.getObject(2);
                    while (rs2.next()) {
                        tempEnt.setIdentidad(rs2.getLong("IDENTIDAD"));
                        tempEnt.setNombre(rs2.getString("NOMBRE"));
                        tempEnt.setUser(rs2.getString("USER_"));
                        tempEnt.setPass(rs2.getString("PASS"));
                        tempEnt.setDireccion(rs2.getString("DIRECCION"));
                        tempEnt.setTelefono(rs2.getString("TELEFONO"));
                        tempEnt.setPais(rs2.getString("PAIS"));
                        tempEnt.setResolAuto(rs2.getString("RESOL_AUTO"));
                        tempEnt.setFechaResol(rs2.getDate("FECHA_RESOL"));
                        tempEnt.setResolRenov(rs2.getString("RESOL_RENOV"));
                        tempEnt.setFechaRenov(rs2.getDate("FECHA_RENOV"));
                        tempEnt.setFechaVenc(rs2.getDate("FECHA_VENC"));
                        tempEnt.setObs(rs2.getString("OBS"));
                    }
                    rs2.close();
                    statement2.close();
                    tempFam.setEntidad(tempEnt);
                }
                tempEF.setFamilia(tempFam);
                tempEst.setExpedienteFamilia(tempEF);
                tempEst.setPrioridad(rs.getLong("PRIORIDAD"));
                tempEst.setFechaEstudio(rs.getDate("FECHA_ESTUDIO"));
                tempEst.setFechaSolAdop(rs.getDate("FECHA_SOL_ADOP"));
                listaEstudio.add(tempEst);
            }
            rs.close();
            statement.close();
        }
    };
    session.doWork(work);

    return listaEstudio;
}

From source file:com.mimp.hibernate.HiberReporte.java

public ArrayList<EstudioCaso> getSolicitudAdopcionMensual(Long idNna) {
    Session session = sessionFactory.getCurrentSession();
    session.beginTransaction();/*  w w  w .  ja v a2  s  . co  m*/

    final Long idN = idNna;
    final ArrayList<EstudioCaso> listaEstudio = new ArrayList();
    Work work = new Work() {
        @Override
        public void execute(Connection connection) throws SQLException {

            String hql = "{call REPORTE_SOLICITUD_MENSUAL(?,?)}";
            CallableStatement statement = connection.prepareCall(hql);
            statement.setLong(1, idN);
            statement.registerOutParameter(2, OracleTypes.CURSOR);
            statement.execute();

            ResultSet rs = (ResultSet) statement.getObject(2);

            while (rs.next()) {
                EstudioCaso tempEst = new EstudioCaso();
                ExpedienteFamilia tempEF = new ExpedienteFamilia();
                Familia tempFam = new Familia();
                Entidad tempEnt = new Entidad();

                tempEF.setIdexpedienteFamilia(rs.getLong("IDEXPEDIENTE_FAMILIA"));
                tempEF.setExpediente(rs.getString("EXPEDIENTE"));
                tempEF.setNacionalidad(rs.getString("NACIONALIDAD"));

                tempFam.setIdfamilia(rs.getLong("IDFAMILIA"));
                Long idEntidad = rs.getLong("IDENTIDAD");
                if (!rs.wasNull()) {
                    String query2 = "{call RENAD_ENTIDAD(?,?)}";
                    CallableStatement statement2 = connection.prepareCall(query2);
                    statement2.setLong(1, idEntidad);
                    statement2.registerOutParameter(2, OracleTypes.CURSOR);
                    statement2.execute();
                    ResultSet rs2 = (ResultSet) statement2.getObject(2);
                    while (rs2.next()) {
                        tempEnt.setIdentidad(rs2.getLong("IDENTIDAD"));
                        tempEnt.setNombre(rs2.getString("NOMBRE"));
                        tempEnt.setUser(rs2.getString("USER_"));
                        tempEnt.setPass(rs2.getString("PASS"));
                        tempEnt.setDireccion(rs2.getString("DIRECCION"));
                        tempEnt.setTelefono(rs2.getString("TELEFONO"));
                        tempEnt.setPais(rs2.getString("PAIS"));
                        tempEnt.setResolAuto(rs2.getString("RESOL_AUTO"));
                        tempEnt.setFechaResol(rs2.getDate("FECHA_RESOL"));
                        tempEnt.setResolRenov(rs2.getString("RESOL_RENOV"));
                        tempEnt.setFechaRenov(rs2.getDate("FECHA_RENOV"));
                        tempEnt.setFechaVenc(rs2.getDate("FECHA_VENC"));
                        tempEnt.setObs(rs2.getString("OBS"));
                    }
                    rs2.close();
                    statement2.close();
                    tempFam.setEntidad(tempEnt);
                }
                tempEF.setFamilia(tempFam);
                tempEst.setExpedienteFamilia(tempEF);
                tempEst.setPrioridad(rs.getLong("PRIORIDAD"));
                tempEst.setFechaEstudio(rs.getDate("FECHA_ESTUDIO"));
                tempEst.setFechaSolAdop(rs.getDate("FECHA_SOL_ADOP"));
                listaEstudio.add(tempEst);
            }
            rs.close();
            statement.close();
        }
    };
    session.doWork(work);

    return listaEstudio;
}

From source file:com.mimp.hibernate.HiberReporte.java

public ArrayList<EstudioCaso> getSolicitudAdopcionHistorico(Long idNna) {
    Session session = sessionFactory.getCurrentSession();
    session.beginTransaction();/*from   ww  w  .  ja  v  a 2 s.  co m*/

    final Long idN = idNna;
    final ArrayList<EstudioCaso> listaEstudio = new ArrayList();
    Work work = new Work() {
        @Override
        public void execute(Connection connection) throws SQLException {

            String hql = "{call REPORTE_SOLICITUD_HISTORICO(?,?)}";
            CallableStatement statement = connection.prepareCall(hql);
            statement.setLong(1, idN);
            statement.registerOutParameter(2, OracleTypes.CURSOR);
            statement.execute();

            ResultSet rs = (ResultSet) statement.getObject(2);

            while (rs.next()) {
                EstudioCaso tempEst = new EstudioCaso();
                ExpedienteFamilia tempEF = new ExpedienteFamilia();
                Familia tempFam = new Familia();
                Entidad tempEnt = new Entidad();

                tempEF.setIdexpedienteFamilia(rs.getLong("IDEXPEDIENTE_FAMILIA"));
                tempEF.setExpediente(rs.getString("EXPEDIENTE"));
                tempEF.setNacionalidad(rs.getString("NACIONALIDAD"));

                tempFam.setIdfamilia(rs.getLong("IDFAMILIA"));
                Long idEntidad = rs.getLong("IDENTIDAD");
                if (!rs.wasNull()) {
                    String query2 = "{call RENAD_ENTIDAD(?,?)}";
                    CallableStatement statement2 = connection.prepareCall(query2);
                    statement2.setLong(1, idEntidad);
                    statement2.registerOutParameter(2, OracleTypes.CURSOR);
                    statement2.execute();
                    ResultSet rs2 = (ResultSet) statement2.getObject(2);
                    while (rs2.next()) {
                        tempEnt.setIdentidad(rs2.getLong("IDENTIDAD"));
                        tempEnt.setNombre(rs2.getString("NOMBRE"));
                        tempEnt.setUser(rs2.getString("USER_"));
                        tempEnt.setPass(rs2.getString("PASS"));
                        tempEnt.setDireccion(rs2.getString("DIRECCION"));
                        tempEnt.setTelefono(rs2.getString("TELEFONO"));
                        tempEnt.setPais(rs2.getString("PAIS"));
                        tempEnt.setResolAuto(rs2.getString("RESOL_AUTO"));
                        tempEnt.setFechaResol(rs2.getDate("FECHA_RESOL"));
                        tempEnt.setResolRenov(rs2.getString("RESOL_RENOV"));
                        tempEnt.setFechaRenov(rs2.getDate("FECHA_RENOV"));
                        tempEnt.setFechaVenc(rs2.getDate("FECHA_VENC"));
                        tempEnt.setObs(rs2.getString("OBS"));
                    }
                    rs2.close();
                    statement2.close();
                    tempFam.setEntidad(tempEnt);
                }
                tempEF.setFamilia(tempFam);
                tempEst.setExpedienteFamilia(tempEF);
                tempEst.setPrioridad(rs.getLong("PRIORIDAD"));
                tempEst.setFechaEstudio(rs.getDate("FECHA_ESTUDIO"));
                tempEst.setFechaSolAdop(rs.getDate("FECHA_SOL_ADOP"));
                listaEstudio.add(tempEst);
            }
            rs.close();
            statement.close();
        }
    };
    session.doWork(work);

    return listaEstudio;
}

From source file:com.mimp.hibernate.HiberReporte.java

public ArrayList<FormularioSesion> getAsistenciaSI(Long idsesion) {
    Session session = sessionFactory.getCurrentSession();
    session.beginTransaction();// w  w  w .  ja v  a  2 s  . co  m

    final Long idsesion_in = idsesion;
    final ArrayList<FormularioSesion> allFamilias = new ArrayList();
    Work work = new Work() {
        @Override
        public void execute(Connection connection) throws SQLException {

            String hql = "{call REPORTE_ASISTENCIA_SESION(?,?,?)}";
            CallableStatement statement = connection.prepareCall(hql);
            statement.setLong(1, idsesion_in);
            statement.registerOutParameter(2, OracleTypes.CURSOR);
            statement.registerOutParameter(3, OracleTypes.CURSOR);
            statement.execute();

            ResultSet rs2 = (ResultSet) statement.getObject(2);
            ResultSet rs = (ResultSet) statement.getObject(3);

            Sesion sesion = new Sesion();

            while (rs2.next()) {
                sesion.setIdsesion(rs2.getLong("IDSESION"));
                sesion.setNSesion(rs2.getString("N_SESION"));
                sesion.setHabilitado(rs2.getShort("HABILITADO"));
                sesion.setFecha(rs2.getDate("FECHA"));
                sesion.setHora(rs2.getString("HORA"));
                sesion.setDireccion(rs2.getString("DIRECCION"));
                sesion.setDuracion(rs2.getString("DURACION"));
                sesion.setFacilitador(rs2.getString("FACILITADOR"));
                sesion.setAsistencia(rs2.getShort("ASISTENCIA"));
                sesion.setUnidad(rs2.getString("UNIDAD"));
            }
            rs2.close();

            while (rs.next()) {
                FormularioSesion form = new FormularioSesion();
                form.setSesion(sesion);
                form.setIdformularioSesion(rs.getLong("IDFORMULARIO_SESION"));
                form.setFechaSol(rs.getDate("FECHA_SOL"));
                form.setPaisRes(rs.getString("PAIS_RES"));
                form.setDepRes(rs.getString("DEP_RES"));
                form.setProvRes(rs.getString("PROV_RES"));
                form.setDistritoRes(rs.getString("DISTRITO_RES"));
                form.setDireccionRes(rs.getString("DIRECCION_RES"));
                form.setEstadoCivil(rs.getString("ESTADO_CIVIL"));
                form.setTelefono(rs.getString("TELEFONO"));

                Long idfamilia = rs.getLong("IDFAMILIA");

                if (idfamilia != 0) {
                    form.setFamilia(servicioEtapa.getFamilia(idfamilia));
                } else {
                    Familia fami = new Familia();
                    fami.setIdfamilia(0);
                    form.setFamilia(fami);
                }

                Set<AsistenciaFT> listAsistencia = getAsistencia(rs.getLong("IDFORMULARIO_SESION"));
                form.setAsistenciaFTs(listAsistencia);

                Set<Asistente> listAsist = getAsistentes(rs.getLong("IDFORMULARIO_SESION"));
                form.setAsistentes(listAsist);

                allFamilias.add(form);
            }
            rs.close();
            statement.close();
        }
    };
    session.doWork(work);

    //METODO BUBBLESORT PARA ORDENAR SEGUN EL APELLIDO DE LA ASISTENTE MUJER
    int n = allFamilias.size();
    FormularioSesion auxform;
    for (int i = 0; i < n - 1; i++) {
        ArrayList<Asistente> asist_temp = new ArrayList(allFamilias.get(i).getAsistentes());
        for (int j = i; j < n - 1; j++) {
            ArrayList<Asistente> asist_temp2 = new ArrayList(allFamilias.get(j + 1).getAsistentes());
            if (asist_temp.get(0).getApellidoP().compareToIgnoreCase(asist_temp2.get(0).getApellidoP()) > 0) {
                auxform = allFamilias.get(i);
                allFamilias.set(i, allFamilias.get(j + 1));
                allFamilias.set(j + 1, auxform);
            }
        }
    }

    return allFamilias;
}

From source file:com.mimp.hibernate.HiberReporte.java

public Set<AsistenciaFT> getAsistencia(Long idformulario) {
    Session session = sessionFactory.getCurrentSession();
    session.beginTransaction();/*w  w  w  .  ja va 2s  .co m*/

    final Long idform = idformulario;
    final Set<AsistenciaFT> listaAsist = new HashSet<AsistenciaFT>();
    Work work = new Work() {
        @Override
        public void execute(Connection connection) throws SQLException {

            String hql2 = "{call REPORTE_GET_ASISTENCIA(?,?)}";
            CallableStatement statement2 = connection.prepareCall(hql2);
            statement2.setLong(1, idform);
            statement2.registerOutParameter(2, OracleTypes.CURSOR);
            statement2.execute();

            ResultSet rs2 = (ResultSet) statement2.getObject(2);

            AsistenciaFT asist;
            while (rs2.next()) {
                asist = new AsistenciaFT();
                asist.setIdasistenciaFT(rs2.getLong("IDASISTENCIA_F_T"));
                if (!rs2.wasNull()) {
                    asist.setAsistencia(rs2.getString("ASISTENCIA").charAt(0));
                }
                asist.setInasJus(rs2.getShort("INAS_JUS"));

                listaAsist.add(asist);
            }
            rs2.close();
            statement2.close();
        }
    };
    session.doWork(work);

    return listaAsist;
}

From source file:com.mimp.hibernate.HiberReporte.java

public Designacion getFamiliaDesignadoNna(Long idNna) {
    Session session = sessionFactory.getCurrentSession();
    session.beginTransaction();//www.  j  a v  a  2s  .  c o  m

    final Long idN = idNna;
    final Designacion tempDesig = new Designacion();
    Work work = new Work() {
        @Override
        public void execute(Connection connection) throws SQLException {

            String hql = "{call REPORTE_NNA_DESIG(?,?)}";
            CallableStatement statement = connection.prepareCall(hql);
            statement.setLong(1, idN);
            statement.registerOutParameter(2, OracleTypes.CURSOR);
            statement.execute();

            ResultSet rs = (ResultSet) statement.getObject(2);

            if (rs.next()) {
                Set<InfoFamilia> listInf = new HashSet<InfoFamilia>();
                InfoFamilia tempInfo = new InfoFamilia();
                ExpedienteFamilia tempEF = new ExpedienteFamilia();
                Familia tempFam = new Familia();
                Entidad tempEnt = new Entidad();

                tempEF.setIdexpedienteFamilia(rs.getLong("IDEXPEDIENTE_FAMILIA"));
                tempEF.setExpediente(rs.getString("EXPEDIENTE"));
                tempEF.setNacionalidad(rs.getString("NACIONALIDAD"));

                tempFam.setIdfamilia(rs.getLong("IDFAMILIA"));
                tempInfo.setPaisRes(rs.getString("PAIS_RES"));
                tempInfo.setDepRes(rs.getString("DEP_RES"));
                listInf.add(tempInfo);
                tempFam.setInfoFamilias(listInf);
                Long idEntidad = rs.getLong("IDENTIDAD");
                if (!rs.wasNull()) {
                    String query2 = "{call RENAD_ENTIDAD(?,?)}";
                    CallableStatement statement2 = connection.prepareCall(query2);
                    statement2.setLong(1, idEntidad);
                    statement2.registerOutParameter(2, OracleTypes.CURSOR);
                    statement2.execute();
                    ResultSet rs2 = (ResultSet) statement2.getObject(2);
                    while (rs2.next()) {
                        tempEnt.setIdentidad(rs2.getLong("IDENTIDAD"));
                        tempEnt.setNombre(rs2.getString("NOMBRE"));
                        tempEnt.setUser(rs2.getString("USER_"));
                        tempEnt.setPass(rs2.getString("PASS"));
                        tempEnt.setDireccion(rs2.getString("DIRECCION"));
                        tempEnt.setTelefono(rs2.getString("TELEFONO"));
                        tempEnt.setPais(rs2.getString("PAIS"));
                        tempEnt.setResolAuto(rs2.getString("RESOL_AUTO"));
                        tempEnt.setFechaResol(rs2.getDate("FECHA_RESOL"));
                        tempEnt.setResolRenov(rs2.getString("RESOL_RENOV"));
                        tempEnt.setFechaRenov(rs2.getDate("FECHA_RENOV"));
                        tempEnt.setFechaVenc(rs2.getDate("FECHA_VENC"));
                        tempEnt.setObs(rs2.getString("OBS"));
                    }
                    rs2.close();
                    statement2.close();
                    tempFam.setEntidad(tempEnt);
                }
                tempEF.setFamilia(tempFam);
                tempDesig.setExpedienteFamilia(tempEF);
                tempDesig.setFechaConsejo(rs.getDate("FECHA_CONSEJO"));
            }
            rs.close();
            statement.close();
        }
    };
    session.doWork(work);

    return tempDesig;
}

From source file:com.mimp.hibernate.HiberReporte.java

public Taller getTaller(Long idtaller) {
    Session session = sessionFactory.getCurrentSession();
    session.beginTransaction();/*from   w  w  w  . j a v  a  2 s . c o  m*/

    final Long idtaller_in = idtaller;
    final Taller taller = new Taller();
    Work work = new Work() {
        @Override
        public void execute(Connection connection) throws SQLException {

            String hql2 = "{call REPORTE_GET_TALLER(?,?)}";
            CallableStatement statement2 = connection.prepareCall(hql2);
            statement2.setLong(1, idtaller_in);
            statement2.registerOutParameter(2, OracleTypes.CURSOR);
            statement2.execute();

            ResultSet rs2 = (ResultSet) statement2.getObject(2);

            while (rs2.next()) {
                taller.setIdtaller(idtaller_in);
                taller.setNSesion(rs2.getString("N_SESION"));
                taller.setTipoTaller(rs2.getString("TIPO_TALLER"));
                taller.setNombre(rs2.getString("NOMBRE"));
                taller.setHabilitado(rs2.getShort("HABILITADO"));
                taller.setNReunion(rs2.getShort("N_REUNION"));
            }
            rs2.close();
            statement2.close();
        }
    };
    session.doWork(work);

    return taller;
}

From source file:com.mimp.hibernate.HiberReporte.java

public Grupo getGrupo(Long idgrupo) {
    Session session = sessionFactory.getCurrentSession();
    session.beginTransaction();/*from  w w w . j  ava 2s .c o  m*/

    final Long idgrupo_in = idgrupo;
    final Grupo grupo = new Grupo();
    Work work = new Work() {
        @Override
        public void execute(Connection connection) throws SQLException {

            String hql2 = "{call REPORTE_GET_GRUPO(?,?)}";
            CallableStatement statement2 = connection.prepareCall(hql2);
            statement2.setLong(1, idgrupo_in);
            statement2.registerOutParameter(2, OracleTypes.CURSOR);
            statement2.execute();

            ResultSet rs2 = (ResultSet) statement2.getObject(2);

            while (rs2.next()) {
                grupo.setIdgrupo(idgrupo_in);
                grupo.setNombre(rs2.getString("NOMBRE"));
            }
            rs2.close();
            statement2.close();
        }
    };
    session.doWork(work);

    return grupo;
}

From source file:com.mimp.hibernate.HiberReporte.java

public Turno2 getTurno2(Long idturno2) {
    Session session = sessionFactory.getCurrentSession();
    session.beginTransaction();//w  ww .j  a  v a2  s. co m

    final Long idturno2_in = idturno2;
    final Turno2 turno2 = new Turno2();
    Work work = new Work() {
        @Override
        public void execute(Connection connection) throws SQLException {

            String hql2 = "{call REPORTE_GET_TURNO2(?,?)}";
            CallableStatement statement2 = connection.prepareCall(hql2);
            statement2.setLong(1, idturno2_in);
            statement2.registerOutParameter(2, OracleTypes.CURSOR);
            statement2.execute();

            ResultSet rs2 = (ResultSet) statement2.getObject(2);

            while (rs2.next()) {
                turno2.setIdturno2(idturno2_in);
                turno2.setNombre(rs2.getString("NOMBRE"));
            }
            rs2.close();
            statement2.close();
        }
    };
    session.doWork(work);

    return turno2;
}