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.HiberNna.java

public ArrayList<Nna> ListaNnaSeguimiento(String clasificacion) {
    Session session = sessionFactory.getCurrentSession();
    final String clasif = clasificacion;
    final ArrayList<Nna> allNna = new ArrayList();
    final ArrayList<Nna> allNnaAux = new ArrayList();
    final ArrayList<Nna> allNnaFinal = new ArrayList();

    Work work = new Work() {
        @Override//from   w  w  w. j  av a  2s.  com
        public void execute(Connection connection) throws SQLException {
            ExpedienteNna expnna;
            Nna tempnna;
            Designacion desig;

            EstudioCaso est;

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

            temp = (ResultSet) statement.getObject(1);

            while (temp.next()) {
                tempnna = new Nna();
                tempnna.setIdnna(temp.getLong(1));
                tempnna.setNombre(temp.getString(2));
                tempnna.setApellidoP(temp.getString(3));
                tempnna.setApellidoM(temp.getString(4));
                tempnna.setSexo(temp.getString(5));
                tempnna.setFechaNacimiento(temp.getDate(6));
                tempnna.setEdadAnhos(temp.getShort(7));
                tempnna.setEdadMeses(temp.getShort(8));
                tempnna.setActaNacimiento(temp.getShort(9));
                tempnna.setCondicionSalud(temp.getString(10));
                tempnna.setDepartamentoNacimiento(temp.getString(11));
                tempnna.setProvinciaNacimiento(temp.getString(12));
                tempnna.setDistritoNacimiento(temp.getString(13));
                tempnna.setPaisNacimiento(temp.getString(14));
                tempnna.setLugarNac(temp.getString(15));
                tempnna.setFechaResolAbandono(temp.getDate(16));
                tempnna.setFechaResolConsentida(temp.getDate(17));
                tempnna.setClasificacion(temp.getString(18));
                tempnna.setIncesto(temp.getShort(19));
                tempnna.setMental(temp.getShort(20));
                tempnna.setEpilepsia(temp.getShort(21));
                tempnna.setAbuso(temp.getShort(22));
                tempnna.setSifilis(temp.getShort(23));
                tempnna.setSeguiMedico(temp.getShort(24));
                tempnna.setOperacion(temp.getShort(25));
                tempnna.setHiperactivo(temp.getShort(26));
                tempnna.setEspecial(temp.getShort(27));
                tempnna.setEnfermo(temp.getShort(28));
                tempnna.setMayor(temp.getShort(29));
                tempnna.setAdolescente(temp.getShort(30));
                tempnna.setHermano(temp.getShort(31));
                tempnna.setNn(temp.getShort(32));
                tempnna.setObservaciones(temp.getString(33));
                tempnna.setNResolAband(temp.getString(34));
                tempnna.setNResolCons(temp.getString(35));
                try {
                    expnna = getExpNna(temp.getLong(1));
                    if (expnna.getIdexpedienteNna() != 0) {
                        Set<ExpedienteNna> listexp = new HashSet<ExpedienteNna>();
                        listexp.add(expnna);
                        tempnna.setExpedienteNnas(listexp);
                    }
                } catch (Exception e) {

                }
                allNnaAux.add(tempnna);
            }
            statement.close();
            temp.close();

            //AQUI DESIGNACIONES Y ESTUDIO DE CASOS EN CASO SEA PRIORITARIO
            for (Nna auxnna : allNnaAux) {
                Set<Designacion> listDesig = new HashSet<Designacion>();
                String hql2 = "{call HN_GET_DESIGNACIONES(?,?)}";
                CallableStatement statement2 = connection.prepareCall(hql2);
                statement2.setLong(1, auxnna.getIdnna());
                statement2.registerOutParameter(2, OracleTypes.CURSOR);
                statement2.execute();

                ResultSet rs2 = (ResultSet) statement2.getObject(2);
                while (rs2.next()) {
                    desig = new Designacion();
                    desig.setIddesignacion(rs2.getLong(1));
                    desig.setNDesignacion(rs2.getString(5));
                    desig.setPrioridad(rs2.getLong(6));
                    desig.setFechaPropuesta(rs2.getDate(7));
                    desig.setFechaConsejo(rs2.getDate(8));
                    desig.setAceptacionConsejo(rs2.getShort(9));
                    desig.setTipoPropuesta(rs2.getString(10));
                    desig.setObs(rs2.getString(11));
                    listDesig.add(desig);
                }
                auxnna.setDesignacions(listDesig);
                allNna.add(auxnna);
                statement2.close();
                rs2.close();
            }

            for (Nna auxnna : allNna) {
                if (auxnna.getClasificacion().equals("prioritario")) {
                    Set<EstudioCaso> listEst = new HashSet<EstudioCaso>();
                    String hql3 = "{call HN_GET_ESTUDIOS_CASO(?,?)}";
                    CallableStatement statement3 = connection.prepareCall(hql3);
                    statement3.setLong(1, auxnna.getIdnna());
                    statement3.registerOutParameter(2, OracleTypes.CURSOR);
                    statement3.execute();

                    ResultSet rs3 = (ResultSet) statement3.getObject(2);
                    while (rs3.next()) {
                        est = new EstudioCaso();
                        est.setIdestudioCaso(rs3.getLong(1));
                        est.setOrden(rs3.getString(4));
                        est.setFechaEstudio(rs3.getDate(5));
                        est.setFechaSolAdop(rs3.getDate(6));
                        est.setResultado(rs3.getString(7));
                        est.setPrioridad(rs3.getLong(8));
                        est.setNSolicitud(rs3.getLong(9));
                        listEst.add(est);
                    }
                    auxnna.setEstudioCasos(listEst);
                    statement3.close();
                    rs3.close();
                }
                allNnaFinal.add(auxnna);
            }

            //METODO BUBBLESORT PARA ORDENAR POR CODIGO
            if (clasif.equals("prioritario")) {
                Nna auxnna2;
                int n = allNnaFinal.size();
                for (int i = 0; i < n - 1; i++) {
                    for (int j = i; j < n - 1; j++) {
                        if (allNnaFinal.get(i).getExpedienteNnas().isEmpty()) {
                            if (!allNnaFinal.get(j + 1).getExpedienteNnas().isEmpty()) {
                                auxnna2 = allNnaFinal.get(i);
                                allNnaFinal.set(i, allNnaFinal.get(j + 1));
                                allNnaFinal.set(j + 1, auxnna2);
                            } else {
                                String apellidoPrev = "";
                                String apellidoNext = "";
                                try {
                                    apellidoPrev = allNnaFinal.get(i).getApellidoP();
                                    if (apellidoPrev == null) {
                                        apellidoPrev = "";
                                    }
                                } catch (Exception ex) {
                                    apellidoPrev = "";
                                }
                                try {
                                    apellidoNext = allNnaFinal.get(j + 1).getApellidoP();
                                    if (apellidoNext == null) {
                                        apellidoNext = "";
                                    }
                                } catch (Exception ex) {
                                    apellidoNext = "";
                                }
                                if (apellidoPrev.compareToIgnoreCase(apellidoNext) > 0) {
                                    auxnna2 = allNnaFinal.get(i);
                                    allNnaFinal.set(i, allNnaFinal.get(j + 1));
                                    allNnaFinal.set(j + 1, auxnna2);
                                }
                            }
                        } else {
                            Set<ExpedienteNna> listExp1 = allNnaFinal.get(i).getExpedienteNnas();
                            Set<ExpedienteNna> listExp2 = allNnaFinal.get(j + 1).getExpedienteNnas();
                            if (!listExp2.isEmpty()) {
                                for (ExpedienteNna exp1 : listExp1) {
                                    for (ExpedienteNna exp2 : listExp2) {
                                        String codant = exp1.getCodigoReferencia();
                                        String codpost = exp2.getCodigoReferencia();
                                        if (codant == null) {
                                            codant = "";
                                        }
                                        if (codpost == null) {
                                            codpost = "";
                                        }
                                        if (codant.compareToIgnoreCase(codpost) > 0) {
                                            auxnna2 = allNnaFinal.get(i);
                                            allNnaFinal.set(i, allNnaFinal.get(j + 1));
                                            allNnaFinal.set(j + 1, auxnna2);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    };
    session.doWork(work);

    return allNnaFinal;
}

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

public ExpedienteNna getExpNna(long idNna) {
    Session session = sessionFactory.getCurrentSession();

    final ExpedienteNna expnna = new ExpedienteNna();
    final Long idnna = idNna;

    Work work = new Work() {
        @Override//  w w  w.j  a va2  s.  com
        public void execute(Connection connection) throws SQLException {
            Nna tempnna;

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

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

            while (tempexp.next()) {
                expnna.setIdexpedienteNna(tempexp.getLong(1));
                expnna.setNumero(tempexp.getString(2));
                expnna.setFechaIngreso(tempexp.getDate(3));
                expnna.setHt(tempexp.getString(4));
                expnna.setNExpTutelar(tempexp.getString(5));
                expnna.setProcTutelar(tempexp.getString(6));
                expnna.setFichaIntegral(tempexp.getShort(7));
                expnna.setComentarios(tempexp.getString(8));
                expnna.setRespLegalNombre(tempexp.getString(9));
                expnna.setRespLegalP(tempexp.getString(10));
                expnna.setRespLegalM(tempexp.getString(11));
                expnna.setRespPsicosocialNombre(tempexp.getString(12));
                expnna.setRespPiscosocialP(tempexp.getString(13));
                expnna.setRespPsicosocialM(tempexp.getString(14));
                expnna.setEstado(tempexp.getString(15));
                expnna.setFechaEstado(tempexp.getDate(16));
                expnna.setAdoptable(tempexp.getShort(17));
                expnna.setFechaResolCons(tempexp.getDate(18));
                expnna.setNacional(tempexp.getShort(19));
                expnna.setDiagnostico(tempexp.getString(20));
                expnna.setCodigoReferencia(tempexp.getString(21));
                expnna.setNActual(tempexp.getString(22));
                expnna.setApellidopActual(tempexp.getString(23));
                expnna.setApellidomActual(tempexp.getString(24));
                expnna.setObservaciones(tempexp.getString(25));
                expnna.setFechaInvTutelar(tempexp.getDate(26));
                expnna.setFechaIngPrio(tempexp.getDate("FECHA_ING_PRIO"));
                expnna.setFechaActualizacion(tempexp.getDate("FECHA_ACTUALIZACION"));
                tempnna = new Nna();
                tempnna.setIdnna(tempexp.getLong(27));
                tempnna.setNombre(tempexp.getString(28));
                tempnna.setApellidoP(tempexp.getString(29));
                tempnna.setApellidoM(tempexp.getString(30));
                tempnna.setSexo(tempexp.getString(31));
                tempnna.setFechaNacimiento(tempexp.getDate(32));
                tempnna.setEdadAnhos(tempexp.getShort(33));
                tempnna.setEdadMeses(tempexp.getShort(34));
                tempnna.setActaNacimiento(tempexp.getShort(35));
                tempnna.setCondicionSalud(tempexp.getString(36));
                tempnna.setDepartamentoNacimiento(tempexp.getString(37));
                tempnna.setProvinciaNacimiento(tempexp.getString(38));
                tempnna.setDistritoNacimiento(tempexp.getString(39));
                tempnna.setPaisNacimiento(tempexp.getString(40));
                tempnna.setLugarNac(tempexp.getString(41));
                tempnna.setFechaResolAbandono(tempexp.getDate(42));
                tempnna.setFechaResolConsentida(tempexp.getDate(43));
                tempnna.setClasificacion(tempexp.getString(44));
                tempnna.setIncesto(tempexp.getShort(45));
                tempnna.setMental(tempexp.getShort(46));
                tempnna.setEpilepsia(tempexp.getShort(47));
                tempnna.setAbuso(tempexp.getShort(48));
                tempnna.setSifilis(tempexp.getShort(49));
                tempnna.setSeguiMedico(tempexp.getShort(50));
                tempnna.setOperacion(tempexp.getShort(51));
                tempnna.setHiperactivo(tempexp.getShort(52));
                tempnna.setEspecial(tempexp.getShort(53));
                tempnna.setEnfermo(tempexp.getShort(54));
                tempnna.setMayor(tempexp.getShort(55));
                tempnna.setAdolescente(tempexp.getShort(56));
                tempnna.setHermano(tempexp.getShort(57));
                tempnna.setNn(tempexp.getShort(58));
                tempnna.setObservaciones(tempexp.getString(59));
                tempnna.setNResolAband(tempexp.getString(60));
                tempnna.setNResolCons(tempexp.getString(61));
                expnna.setNna(tempnna);
                Unidad unid = new Unidad();
                unid.setIdunidad(tempexp.getLong(62));
                expnna.setUnidad(unid);
            }
            tempexp.close();
            statement.close();
        }
    };
    session.doWork(work);
    return expnna;
}

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

public ArrayList<ExpedienteNna> listaExpNna() {
    Session session = sessionFactory.getCurrentSession();
    final ArrayList<ExpedienteNna> allExpNna = new ArrayList();

    Work work = new Work() {
        @Override/*from w  w  w.  ja v a2 s  . co  m*/
        public void execute(Connection connection) throws SQLException {
            ExpedienteNna expnna;

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

            temp = (ResultSet) statement.getObject(1);

            while (temp.next()) {
                expnna = new ExpedienteNna();
                expnna.setIdexpedienteNna(temp.getShort(1));
                expnna.setNumero(temp.getString(4));
                expnna.setFechaIngreso(temp.getDate(5));
                expnna.setHt(temp.getString(6));
                expnna.setNExpTutelar(temp.getString(7));
                expnna.setProcTutelar(temp.getString(8));
                expnna.setFichaIntegral(temp.getShort(9));
                expnna.setComentarios(temp.getString(10));
                expnna.setRespLegalNombre(temp.getString(11));
                expnna.setRespLegalP(temp.getString(12));
                expnna.setRespLegalM(temp.getString(13));
                expnna.setRespPsicosocialNombre(temp.getString(14));
                expnna.setRespPiscosocialP(temp.getString(15));
                expnna.setRespPsicosocialM(temp.getString(16));
                expnna.setEstado(temp.getString(17));
                expnna.setFechaEstado(temp.getDate(18));
                expnna.setAdoptable(temp.getShort(19));
                expnna.setFechaResolCons(temp.getDate(20));
                expnna.setNacional(temp.getShort(21));
                expnna.setDiagnostico(temp.getString(22));
                expnna.setCodigoReferencia(temp.getString(23));
                expnna.setNActual(temp.getString(24));
                expnna.setApellidopActual(temp.getString(25));
                expnna.setApellidomActual(temp.getString(26));
                expnna.setObservaciones(temp.getString(27));
                expnna.setFechaInvTutelar(temp.getDate(28));
                allExpNna.add(expnna);
            }
            temp.close();
            statement.close();
        }
    };
    session.doWork(work);
    return allExpNna;
}

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

public void crearExpNna(ExpedienteNna temp) {

    Session session = sessionFactory.getCurrentSession();
    session.beginTransaction();/*from www  . j a  v  a2s .c o m*/
    final ExpedienteNna expnna = temp;

    Work work = new Work() {
        @Override
        public void execute(Connection connection) throws SQLException {

            String hql = "{call HN_SAVE_EXP_NNA(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}";
            CallableStatement statement = connection.prepareCall(hql);
            statement.setLong(1, expnna.getNna().getIdnna());
            statement.setLong(2, expnna.getUnidad().getIdunidad());
            statement.setString(3, expnna.getNumero());
            statement.setDate(4, (java.sql.Date) expnna.getFechaIngreso());
            statement.setString(5, expnna.getHt());
            statement.setString(6, expnna.getNExpTutelar());
            statement.setString(7, expnna.getProcTutelar());
            statement.setShort(8, expnna.getFichaIntegral());
            statement.setString(9, expnna.getComentarios());
            statement.setString(10, expnna.getRespLegalNombre());
            statement.setString(11, expnna.getRespLegalP());
            statement.setString(12, expnna.getRespLegalM());
            statement.setString(13, expnna.getRespPsicosocialNombre());
            statement.setString(14, expnna.getRespPiscosocialP());
            statement.setString(15, expnna.getRespPsicosocialM());
            statement.setString(16, expnna.getEstado());
            statement.setDate(17, (java.sql.Date) expnna.getFechaEstado());
            statement.setShort(18, expnna.getAdoptable());
            statement.setDate(19, (java.sql.Date) expnna.getFechaResolCons());
            statement.setShort(20, expnna.getNacional());
            statement.setString(21, expnna.getDiagnostico());
            statement.setString(22, expnna.getCodigoReferencia());
            statement.setString(23, expnna.getNActual());
            statement.setString(24, expnna.getApellidopActual());
            statement.setString(25, expnna.getApellidomActual());
            statement.setString(26, expnna.getObservaciones());
            statement.setDate(27, (java.sql.Date) expnna.getFechaInvTutelar());
            statement.setDate(28, (java.sql.Date) expnna.getFechaIngPrio());
            statement.setDate(29, (java.sql.Date) expnna.getFechaActualizacion());

            statement.execute();
            statement.close();
        }
    };
    session.doWork(work);
}

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

public void updateExpNna(ExpedienteNna temp) {

    Session session = sessionFactory.getCurrentSession();
    session.beginTransaction();//from  w w w . jav  a  2  s  . c om
    final ExpedienteNna expnna = temp;

    Work work = new Work() {
        @Override
        public void execute(Connection connection) throws SQLException {

            String hql = "{call HN_UPDATE_EXP_NNA(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}";
            CallableStatement statement = connection.prepareCall(hql);
            statement.setLong(1, expnna.getNna().getIdnna());
            statement.setLong(2, expnna.getUnidad().getIdunidad());
            statement.setString(3, expnna.getNumero());
            statement.setDate(4, (java.sql.Date) expnna.getFechaIngreso());
            statement.setString(5, expnna.getHt());
            statement.setString(6, expnna.getNExpTutelar());
            statement.setString(7, expnna.getProcTutelar());
            statement.setShort(8, expnna.getFichaIntegral());
            statement.setString(9, expnna.getComentarios());
            statement.setString(10, expnna.getRespLegalNombre());
            statement.setString(11, expnna.getRespLegalP());
            statement.setString(12, expnna.getRespLegalM());
            statement.setString(13, expnna.getRespPsicosocialNombre());
            statement.setString(14, expnna.getRespPiscosocialP());
            statement.setString(15, expnna.getRespPsicosocialM());
            statement.setString(16, expnna.getEstado());
            statement.setDate(17, (java.sql.Date) expnna.getFechaEstado());
            statement.setShort(18, expnna.getAdoptable());
            statement.setDate(19, (java.sql.Date) expnna.getFechaResolCons());
            statement.setShort(20, expnna.getNacional());
            statement.setString(21, expnna.getDiagnostico());
            statement.setString(22, expnna.getCodigoReferencia());
            statement.setString(23, expnna.getNActual());
            statement.setString(24, expnna.getApellidopActual());
            statement.setString(25, expnna.getApellidomActual());
            statement.setString(26, expnna.getObservaciones());
            statement.setDate(27, (java.sql.Date) expnna.getFechaInvTutelar());
            statement.setLong(28, expnna.getIdexpedienteNna());
            statement.setDate(29, (java.sql.Date) expnna.getFechaIngPrio());
            statement.setDate(30, (java.sql.Date) expnna.getFechaActualizacion());

            statement.execute();
            statement.close();
        }
    };
    session.doWork(work);
}

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

public ArrayList<InformeNna> listaInformesExpNna(Long idExpNna) {

    Session session = sessionFactory.getCurrentSession();
    session.beginTransaction();//from w  w w. ja  v  a2  s  .c om
    final Long expNna = idExpNna;
    final ArrayList<InformeNna> lista = new ArrayList();

    Work work = new Work() {
        @Override
        public void execute(Connection connection) throws SQLException {

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

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

            while (rs.next()) {
                InformeNna tempInf = new InformeNna();
                tempInf.setIdinformeNna(rs.getLong("IDINFORME_NNA"));
                tempInf.setNumero(rs.getString("NUMERO"));
                tempInf.setFecha(rs.getDate("FECHA"));
                lista.add(tempInf);

            }

            rs.close();
            statement.close();
        }
    };
    session.doWork(work);
    return lista;
}

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

public void crearInforme(InformeNna tempInf, Long idExp) {

    Session session = sessionFactory.getCurrentSession();
    session.beginTransaction();//  w ww .j  a v  a 2s  .  co m

    final InformeNna inf = tempInf;
    final Long id = idExp;

    Work work = new Work() {
        @Override
        public void execute(Connection connection) throws SQLException {

            String hql = "{call HN_INSERT_INF(?,?,?,?,?)}";
            CallableStatement statement = connection.prepareCall(hql);
            statement.setLong(1, id);
            statement.setString(2, inf.getNumero());
            statement.setDate(3, (java.sql.Date) inf.getFecha());
            statement.setString(4, inf.getResultado());
            statement.setString(5, inf.getObservaciones());

            statement.execute();
            statement.close();
        }
    };

    session.doWork(work);

}

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

public InformeNna InformeExpNna(Long idInforme) {

    Session session = sessionFactory.getCurrentSession();
    session.beginTransaction();/* w w  w  . j a v a  2 s  . com*/
    final Long id = idInforme;
    final InformeNna temp = new InformeNna();

    Work work = new Work() {
        @Override
        public void execute(Connection connection) throws SQLException {

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

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

            if (rs.next()) {
                temp.setIdinformeNna(rs.getLong("IDINFORME_NNA"));
                temp.setNumero(rs.getString("NUMERO"));
                temp.setFecha(rs.getDate("FECHA"));
                temp.setResultado(rs.getString("RESULTADO"));
                temp.setObservaciones(rs.getString("OBSERVACIONES"));
            }

            rs.close();
            statement.close();
        }
    };
    session.doWork(work);
    return temp;
}

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

public void updateInforme(InformeNna temp) {

    Session session = sessionFactory.getCurrentSession();
    session.beginTransaction();//www  .  j a v a 2  s .co  m

    final InformeNna inf = temp;

    Work work = new Work() {
        @Override
        public void execute(Connection connection) throws SQLException {

            String hql = "{call HN_UPDATE_INF(?,?,?,?,?)}";
            CallableStatement statement = connection.prepareCall(hql);
            statement.setLong(1, inf.getIdinformeNna());
            statement.setString(2, inf.getNumero());
            statement.setDate(3, (java.sql.Date) inf.getFecha());
            statement.setString(4, inf.getResultado());
            statement.setString(5, inf.getObservaciones());

            statement.execute();
            statement.close();
        }
    };

    session.doWork(work);

}

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

public String get_Last_numero_expediente() {
    Session session = sessionFactory.getCurrentSession();
    Work work;/*from  w  ww. ja v a2  s .c  o m*/
    work = new Work() {
        @Override
        public void execute(Connection connection) throws SQLException {
            numero_last = null;
            ResultSet temp_numero;
            String hql = "{call HN_GET_LAST_EXPEDIENTE_NNA(?)}";
            CallableStatement statement = connection.prepareCall(hql);
            statement.registerOutParameter(1, OracleTypes.CURSOR);
            statement.execute();

            temp_numero = (ResultSet) statement.getObject(1);
            while (temp_numero.next()) {
                numero_last = temp_numero.getString(2);
            }
            temp_numero.close();
            statement.close();
        }
    };
    session.doWork(work);

    return numero_last;
}