List of usage examples for org.hibernate Session doWork
void doWork(Work work) throws HibernateException;
From source file:com.mimp.hibernate.HiberReporte.java
public Set<Reunion> getReunion(Long idturno2) { Session session = sessionFactory.getCurrentSession(); session.beginTransaction();/*from w w w. ja v a 2 s . c o m*/ final Long idturno2_in = idturno2; final Set<Reunion> listareunion = new HashSet<Reunion>(); Work work = new Work() { @Override public void execute(Connection connection) throws SQLException { String hql2 = "{call REPORTE_GET_REUNIONES(?,?)}"; CallableStatement statement2 = connection.prepareCall(hql2); statement2.setLong(1, idturno2_in); statement2.registerOutParameter(2, OracleTypes.CURSOR); statement2.execute(); ResultSet rs2 = (ResultSet) statement2.getObject(2); Reunion reunion; while (rs2.next()) { reunion = new Reunion(); reunion.setIdreunion(rs2.getLong("IDREUNION")); reunion.setFecha(rs2.getDate("FECHA")); reunion.setHora(rs2.getString("HORA")); reunion.setDuracion(rs2.getString("DURACION")); reunion.setDireccion(rs2.getString("DIRECCION")); reunion.setIdentificador(rs2.getShort("IDENTIFICADOR")); reunion.setFacilitador(rs2.getString("FACILITADOR")); reunion.setCapacidad(rs2.getShort("CAPACIDAD")); reunion.setAsistencia(rs2.getShort("ASISTENCIA")); reunion.setUnidad(rs2.getString("UNIDAD")); listareunion.add(reunion); } rs2.close(); statement2.close(); } }; session.doWork(work); return listareunion; }
From source file:com.mimp.hibernate.HiberReporte.java
public Set<AsistenciaFR> getAsistenciasFR(Long idreunion) { Session session = sessionFactory.getCurrentSession(); session.beginTransaction();//from w w w . ja v a 2s. c o m final Long idreunion_in = idreunion; final Set<AsistenciaFR> listaAsist = new HashSet<AsistenciaFR>(); final Set<AsistenciaFR> listaAsistAux = new HashSet<AsistenciaFR>(); Work work = new Work() { @Override public void execute(Connection connection) throws SQLException { String hql2 = "{call REPORTE_GET_ASISTENCIA_REUNION(?,?)}"; CallableStatement statement2 = connection.prepareCall(hql2); statement2.setLong(1, idreunion_in); statement2.registerOutParameter(2, OracleTypes.CURSOR); statement2.execute(); ResultSet rs2 = (ResultSet) statement2.getObject(2); AsistenciaFR asist; Familia fam; while (rs2.next()) { asist = new AsistenciaFR(); asist.setIdasistenciaFR(rs2.getLong("IDASISTENCIA_F_R")); asist.setAsistencia(rs2.getString("ASISTENCIA").charAt(0)); asist.setInasJus(rs2.getShort("INAS_JUS")); fam = new Familia(); fam.setIdfamilia(rs2.getLong("IDFAMILIA")); asist.setFamilia(fam); listaAsist.add(asist); } rs2.close(); statement2.close(); } }; session.doWork(work); AsistenciaFR asistaux2; for (AsistenciaFR asistaux : listaAsist) { asistaux2 = asistaux; asistaux2.setFamilia(getFamilia(asistaux.getFamilia().getIdfamilia())); listaAsistAux.add(asistaux2); } return listaAsistAux; }
From source file:com.mimp.hibernate.HiberReporte.java
public Familia getFamilia(Long idfamilia) { Session session = sessionFactory.getCurrentSession(); session.beginTransaction();//from w w w . j a v a 2s .com final Long idfamilia_in = idfamilia; final Familia fami = new Familia(); Work work = new Work() { @Override public void execute(Connection connection) throws SQLException { String hql3 = "{call HE_GETFAMILIA(?,?)}"; CallableStatement statement3 = connection.prepareCall(hql3); statement3.setLong(1, idfamilia_in); statement3.registerOutParameter(2, OracleTypes.CURSOR); statement3.execute(); ResultSet rs3 = (ResultSet) statement3.getObject(2); while (rs3.next()) { fami.setIdfamilia(idfamilia_in); fami.setUser(rs3.getString(3)); } rs3.close(); statement3.close(); } }; session.doWork(work); fami.setInfoFamilias(getInfoFam(fami.getIdfamilia())); return fami; }
From source file:com.mimp.hibernate.HiberReporte.java
public Set<InfoFamilia> getInfoFam(Long idfamilia) { Session session = sessionFactory.getCurrentSession(); session.beginTransaction();//from w w w .j av a2s .c o m final Long idfamilia_in = idfamilia; final Set<InfoFamilia> InfoFami = new HashSet<InfoFamilia>(); Work work = new Work() { @Override public void execute(Connection connection) throws SQLException { String hql2 = "{call REPORTE_GET_INFOFAM_POR_IDFAM(?,?)}"; CallableStatement statement2 = connection.prepareCall(hql2); statement2.setLong(1, idfamilia_in); statement2.registerOutParameter(2, OracleTypes.CURSOR); statement2.execute(); ResultSet rs2 = (ResultSet) statement2.getObject(2); InfoFamilia ifa; while (rs2.next()) { ifa = new InfoFamilia(); ifa.setIdinfoFamilia(rs2.getLong("IDINFO_FAMILIA")); ifa.setEstadoCivil(rs2.getString("ESTADO_CIVIL")); InfoFami.add(ifa); } rs2.close(); statement2.close(); } }; session.doWork(work); for (InfoFamilia ifam : InfoFami) { ifam.setAdoptantes(getAdoptantes(ifam.getIdinfoFamilia())); } return InfoFami; }
From source file:com.mimp.hibernate.HiberReporte.java
public Set<Adoptante> getAdoptantes(Long idinfo_fam) { Session session = sessionFactory.getCurrentSession(); session.beginTransaction();//from ww w . ja v a 2 s .com final Long idinfo_fam_in = idinfo_fam; final Set<Adoptante> listaAdop = new HashSet<Adoptante>(); Work work = new Work() { @Override public void execute(Connection connection) throws SQLException { String hql2 = "{call REPORTE_GET_ADOPTANTE(?,?)}"; CallableStatement statement2 = connection.prepareCall(hql2); statement2.setLong(1, idinfo_fam_in); statement2.registerOutParameter(2, OracleTypes.CURSOR); statement2.execute(); ResultSet rs2 = (ResultSet) statement2.getObject(2); Adoptante adopaux; while (rs2.next()) { adopaux = new Adoptante(); adopaux.setNombre(rs2.getString("NOMBRE")); adopaux.setApellidoP(rs2.getString("APELLIDO_P")); adopaux.setApellidoM(rs2.getString("APELLIDO_M")); adopaux.setSexo(rs2.getString("SEXO").charAt(0)); adopaux.setFechaNac(rs2.getDate("FECHA_NAC")); listaAdop.add(adopaux); } rs2.close(); statement2.close(); } }; session.doWork(work); return listaAdop; }
From source file:com.mimp.hibernate.HiberReporte.java
public ArrayList<Designacion> getListaPropuestaDesignacion() { Session session = sessionFactory.getCurrentSession(); final ArrayList<Designacion> allDesig = new ArrayList(); Work work = new Work() { @Override// w w w . j av a 2 s . com public void execute(Connection connection) throws SQLException { String hql = "{call REPORTE_PROP_DESIG(?)}"; CallableStatement statement = connection.prepareCall(hql); statement.registerOutParameter(1, OracleTypes.CURSOR); statement.execute(); ResultSet temp_designacion = (ResultSet) statement.getObject(1); while (temp_designacion.next()) { Designacion designacion = new Designacion(); ExpedienteFamilia expFamilia = new ExpedienteFamilia(); Personal personal = new Personal(); Nna nna = new Nna(); Familia fam = new Familia(); Unidad unidad = new Unidad(); Juzgado juzgado = new Juzgado(); Car car = new Car(); designacion.setIddesignacion(temp_designacion.getLong(1)); if (temp_designacion.getLong(2) != 0) { String hql_designacion_expFamilia = "{call HE_GET_EXPEDIENTE_FAMILIA(?, ?)}"; CallableStatement statement_designacion_expFamilia = connection .prepareCall(hql_designacion_expFamilia); statement_designacion_expFamilia.setLong(1, temp_designacion.getLong(2)); statement_designacion_expFamilia.registerOutParameter(2, OracleTypes.CURSOR); statement_designacion_expFamilia.execute(); ResultSet temp_expediente = (ResultSet) statement_designacion_expFamilia.getObject(2); while (temp_expediente.next()) { expFamilia.setIdexpedienteFamilia(temp_expediente.getLong(1)); if (temp_expediente.getLong(2) != 0) { String hql2 = "{call HE_GETFAMILIA(?, ?)}"; CallableStatement statement2 = connection.prepareCall(hql2); statement2.setLong(1, temp_expediente.getLong(2)); statement2.registerOutParameter(2, OracleTypes.CURSOR); statement2.execute(); ResultSet temp2 = (ResultSet) statement2.getObject(2); while (temp2.next()) { fam.setIdfamilia(temp2.getLong(1)); expFamilia.setFamilia(fam); } temp2.close(); statement2.close(); } if (temp_expediente.getShort(3) != 0) { String hql3 = "{call HE_GET_UNIDAD(?, ?)}"; CallableStatement statement3 = connection.prepareCall(hql3); statement3.setLong(1, temp_expediente.getLong(3)); statement3.registerOutParameter(2, OracleTypes.CURSOR); statement3.execute(); ResultSet temp2 = (ResultSet) statement3.getObject(2); while (temp2.next()) { unidad.setIdunidad(temp2.getLong(1)); unidad.setDepartamento(temp2.getString("DEPARTAMENTO")); expFamilia.setUnidad(unidad); } temp2.close(); statement3.close(); } expFamilia.setNumero(temp_expediente.getLong(4)); expFamilia.setExpediente(temp_expediente.getString(5)); expFamilia.setHt(temp_expediente.getString(6)); expFamilia.setNumeroExpediente(temp_expediente.getString(7)); expFamilia.setFechaIngresoDga(temp_expediente.getDate(8)); expFamilia.setEstado(temp_expediente.getString(9)); expFamilia.setTupa(temp_expediente.getDate(10)); expFamilia.setNacionalidad(temp_expediente.getString(11)); expFamilia.setRnsa(temp_expediente.getShort(12)); expFamilia.setRnaa(temp_expediente.getShort(13)); expFamilia.setTipoFamilia(temp_expediente.getString(14)); expFamilia.setTipoListaEspera(temp_expediente.getString(15)); expFamilia.setHtFicha(temp_expediente.getString(16)); expFamilia.setnFicha(temp_expediente.getString(17)); expFamilia.setFechaIngresoFicha(temp_expediente.getDate(18)); designacion.setExpedienteFamilia(expFamilia); } temp_expediente.close(); statement_designacion_expFamilia.close(); } if (temp_designacion.getLong(3) != 0) { String hql_designacion_NNA = "{call HE_GET_NNA(?, ?)}"; CallableStatement statement_designacion_NNA = connection.prepareCall(hql_designacion_NNA); statement_designacion_NNA.setLong(1, temp_designacion.getLong(3)); statement_designacion_NNA.registerOutParameter(2, OracleTypes.CURSOR); statement_designacion_NNA.execute(); ResultSet temp_nna = (ResultSet) statement_designacion_NNA.getObject(2); while (temp_nna.next()) { nna.setIdnna(temp_nna.getLong(1)); if (temp_nna.getLong(2) != 0) { String hql_designacion_NNA_Juzgado = "{call HE_GET_JUZGADO(?, ?)}"; CallableStatement statement_designacion_NNA_Juzgado = connection .prepareCall(hql_designacion_NNA_Juzgado); statement_designacion_NNA_Juzgado.setLong(1, temp_nna.getLong(2)); statement_designacion_NNA_Juzgado.registerOutParameter(2, OracleTypes.CURSOR); statement_designacion_NNA_Juzgado.execute(); ResultSet temp_juzgado = (ResultSet) statement_designacion_NNA_Juzgado.getObject(2); while (temp_juzgado.next()) { juzgado.setIdjuzgado(temp_juzgado.getLong(1)); nna.setJuzgado(juzgado); } temp_juzgado.close(); statement_designacion_NNA_Juzgado.close(); } if (temp_nna.getLong(3) != 0) { String hql_designacion_NNA_CAR = "{call HE_GET_CAR(?, ?)}"; CallableStatement statement_designacion_NNA_CAR = connection .prepareCall(hql_designacion_NNA_CAR); statement_designacion_NNA_CAR.setLong(1, temp_nna.getLong(3)); statement_designacion_NNA_CAR.registerOutParameter(2, OracleTypes.CURSOR); statement_designacion_NNA_CAR.execute(); ResultSet temp_car = (ResultSet) statement_designacion_NNA_CAR.getObject(2); while (temp_car.next()) { car.setIdcar(temp_car.getLong(1)); car.setNombre(temp_car.getString("NOMBRE")); car.setDepartamento(temp_car.getString("DEPARTAMENTO")); nna.setCar(car); } temp_car.close(); statement_designacion_NNA_CAR.close(); } nna.setNombre(temp_nna.getString(4)); nna.setApellidoP(temp_nna.getString(5)); nna.setApellidoM(temp_nna.getString(6)); nna.setSexo(temp_nna.getString(7)); nna.setFechaNacimiento(temp_nna.getDate(8)); nna.setEdadAnhos(temp_nna.getShort(9)); nna.setEdadMeses(temp_nna.getShort(10)); nna.setActaNacimiento(temp_nna.getShort(11)); nna.setCondicionSalud(temp_nna.getString(12)); nna.setDepartamentoNacimiento(temp_nna.getString(13)); nna.setProvinciaNacimiento(temp_nna.getString(14)); nna.setDistritoNacimiento(temp_nna.getString(15)); nna.setPaisNacimiento(temp_nna.getString(16)); nna.setLugarNac(temp_nna.getString(17)); nna.setFechaResolAbandono(temp_nna.getDate(18)); nna.setFechaResolConsentida(temp_nna.getDate(19)); nna.setClasificacion(temp_nna.getString(20)); nna.setIncesto(temp_nna.getShort(21)); nna.setMental(temp_nna.getShort(22)); nna.setEpilepsia(temp_nna.getShort(23)); nna.setAbuso(temp_nna.getShort(24)); nna.setSifilis(temp_nna.getShort(25)); nna.setSeguiMedico(temp_nna.getShort(26)); nna.setOperacion(temp_nna.getShort(27)); nna.setHiperactivo(temp_nna.getShort(28)); nna.setEspecial(temp_nna.getShort(29)); nna.setEnfermo(temp_nna.getShort(30)); nna.setMayor(temp_nna.getShort(31)); nna.setAdolescente(temp_nna.getShort(32)); nna.setHermano(temp_nna.getShort(33)); nna.setNn(temp_nna.getShort(34)); nna.setObservaciones(temp_nna.getString(35)); nna.setNResolAband(temp_nna.getString(36)); nna.setNResolCons(temp_nna.getString(37)); Set<ExpedienteNna> listaExpNna = new HashSet<ExpedienteNna>(); String hql10 = "{call HN_GET_EXPEDIENTE_NNA_UNO(?,?)}"; CallableStatement statement10 = connection.prepareCall(hql10); statement10.setLong(1, nna.getIdnna()); statement10.registerOutParameter(2, OracleTypes.CURSOR); statement10.execute(); ResultSet rs10 = (ResultSet) statement10.getObject(2); if (rs10.next()) { ExpedienteNna expnna = new ExpedienteNna(); expnna.setIdexpedienteNna(rs10.getLong(1)); expnna.setEstado(rs10.getString(15)); expnna.setCodigoReferencia(rs10.getString(21)); listaExpNna.add(expnna); } rs10.close(); statement10.close(); nna.setExpedienteNnas(listaExpNna); designacion.setNna(nna); } temp_nna.close(); statement_designacion_NNA.close(); } if (temp_designacion.getLong(4) != 0) { String hql_designacion_personal = "{call HE_GET_PERSONAL(?, ?)}"; CallableStatement statement_designacion_personal = connection .prepareCall(hql_designacion_personal); statement_designacion_personal.setLong(1, temp_designacion.getLong(4)); statement_designacion_personal.registerOutParameter(2, OracleTypes.CURSOR); statement_designacion_personal.execute(); ResultSet temp_personal = (ResultSet) statement_designacion_personal.getObject(2); while (temp_personal.next()) { personal.setIdpersonal(temp_personal.getLong(1)); designacion.setPersonal(personal); } temp_personal.close(); statement_designacion_personal.close(); } designacion.setNDesignacion(temp_designacion.getString(5)); designacion.setPrioridad(temp_designacion.getLong(6)); designacion.setFechaPropuesta(temp_designacion.getDate(7)); designacion.setFechaConsejo(temp_designacion.getDate(8)); designacion.setAceptacionConsejo(temp_designacion.getShort(9)); designacion.setTipoPropuesta(temp_designacion.getString(10)); designacion.setObs(temp_designacion.getString(11)); allDesig.add(designacion); } temp_designacion.close(); statement.close(); } }; session.doWork(work); return allDesig; }
From source file:com.mimp.hibernate.HiberReporte.java
public ExpedienteFamilia getInfoFamilia(long id) { Session session = sessionFactory.getCurrentSession(); session.beginTransaction();/*from w w w. j a v a 2 s . c o m*/ final Long idExp = id; final ExpedienteFamilia expFamilia = new ExpedienteFamilia(); Work work = new Work() { @Override public void execute(Connection connection) throws SQLException { ExpedienteNna expnna; String hql = "{call HE_GET_EXPEDIENTE_FAMILIA(?,?)}"; CallableStatement statement = connection.prepareCall(hql); statement.setLong(1, idExp); statement.registerOutParameter(2, OracleTypes.CURSOR); statement.execute(); ResultSet rs = (ResultSet) statement.getObject(2); while (rs.next()) { //ExpedienteFamilia tempEF = new ExpedienteFamilia(); Familia tempFam = new Familia(); Unidad TempUn = new Unidad(); Set<Evaluacion> listaEv = new HashSet<Evaluacion>(); Set<InfoFamilia> listaInf = new HashSet<InfoFamilia>(); expFamilia.setIdexpedienteFamilia(rs.getLong("IDEXPEDIENTE_FAMILIA")); tempFam.setIdfamilia(rs.getLong("IDFAMILIA")); TempUn.setIdunidad(rs.getLong("IDUNIDAD")); expFamilia.setNumero(rs.getLong("NUMERO")); expFamilia.setExpediente(rs.getString("EXPEDIENTE")); expFamilia.setHt(rs.getString("HT")); expFamilia.setNumeroExpediente(rs.getString("NUMERO_EXPEDIENTE")); expFamilia.setFechaIngresoDga(rs.getDate("FECHA_INGRESO_DGA")); expFamilia.setEstado(rs.getString("ESTADO")); expFamilia.setTupa(rs.getDate("TUPA")); expFamilia.setNacionalidad(rs.getString("NACIONALIDAD")); expFamilia.setRnsa(rs.getShort("RNSA")); expFamilia.setRnaa(rs.getShort("RNAA")); expFamilia.setTipoFamilia(rs.getString("TIPO_FAMILIA")); expFamilia.setTipoListaEspera(rs.getString("TIPO_LISTA_ESPERA")); expFamilia.setHtFicha(rs.getString("HTFICHA")); expFamilia.setnFicha(rs.getString("NFICHA")); expFamilia.setFechaIngresoFicha(rs.getDate("FECHA_INGRESO_FICHA")); String hql2 = "{call HE_LISTAEVAL_BY_IDEXPFAM(?,?)}"; CallableStatement statement2 = connection.prepareCall(hql2); statement2.setLong(1, expFamilia.getIdexpedienteFamilia()); statement2.registerOutParameter(2, OracleTypes.CURSOR); statement2.execute(); ResultSet rs2 = (ResultSet) statement2.getObject(2); while (rs2.next()) { Evaluacion tempEval = new Evaluacion(); tempEval.setIdevaluacion(rs2.getLong("IDEVALUACION")); tempEval.setExpedienteFamilia(expFamilia); tempEval.setTipo(rs2.getString("TIPO")); tempEval.setFechaAsignacion(rs2.getDate("FECHA_ASIGNACION")); tempEval.setResultado(rs2.getString("RESULTADO")); tempEval.setFechaResultado(rs2.getDate("FECHA_RESULTADO")); tempEval.setObservacion(rs2.getString("OBSERVACION")); tempEval.setSustento(rs2.getString("SUSTENTO")); tempEval.setNDesignacion(rs2.getString("N_DESIGNACION")); tempEval.setNumEval(rs2.getString("NUM_EVAL")); Set<Resolucion> listaRe = new HashSet<Resolucion>(); if (tempEval.getTipo().equals("legal")) { String hql3 = "{call HE_ULTRESOL_LEGAL(?,?)}"; CallableStatement statement3 = connection.prepareCall(hql3); statement3.setLong(1, tempEval.getIdevaluacion()); statement3.registerOutParameter(2, OracleTypes.CURSOR); statement3.execute(); ResultSet rs3 = (ResultSet) statement3.getObject(2); if (rs3.next()) { Resolucion tempResol = new Resolucion(); tempResol.setIdresolucion(rs3.getLong("IDRESOLUCION")); tempResol.setTipo(rs3.getString("TIPO")); tempResol.setNumero(rs3.getString("NUMERO")); tempResol.setFechaResol(rs3.getDate("FECHA_RESOL")); tempResol.setFechaNotificacion(rs3.getDate("FECHA_NOTIFICACION")); tempResol.setEvaluacion(tempEval); listaRe.add(tempResol); } rs3.close(); statement3.close(); } tempEval.setResolucions(listaRe); listaEv.add(tempEval); } rs2.close(); statement2.close(); String hql4 = "{call HE_GETINFOFAM_POR_IDFAM(?,?)}"; CallableStatement statement4 = connection.prepareCall(hql4); statement4.setLong(1, tempFam.getIdfamilia()); statement4.registerOutParameter(2, OracleTypes.CURSOR); statement4.execute(); ResultSet rs4 = (ResultSet) statement4.getObject(2); if (rs4.next()) { InfoFamilia tempInfo = new InfoFamilia(); tempInfo.setIdinfoFamilia(rs4.getLong("IDINFO_FAMILIA")); tempInfo.setFamilia(tempFam); tempInfo.setDepRes(rs4.getString("DEP_RES")); tempInfo.setPaisRes(rs4.getString("PAIS_RES")); tempInfo.setDomicilio(rs4.getString("DOMICILIO")); tempInfo.setPropiedadVivienda(rs4.getString("PROPIEDAD_VIVIENDA")); tempInfo.setTipoVivienda(rs4.getString("TIPO_VIVIENDA")); tempInfo.setAreaVivTotal(rs4.getLong("AREA_VIV_TOTAL")); tempInfo.setAreaVivConst(rs4.getLong("AREA_VIV_CONST")); tempInfo.setDistVivienda(rs4.getString("DIST_VIVIENDA")); tempInfo.setLuz(rs4.getShort("LUZ")); tempInfo.setAgua(rs4.getShort("AGUA")); tempInfo.setDesague(rs4.getShort("DESAGUE")); tempInfo.setOtrosServ(rs4.getString("OTROS_SERV")); tempInfo.setMaterConst(rs4.getString("MATER_CONST")); tempInfo.setPared(rs4.getString("PARED")); tempInfo.setTecho(rs4.getString("TECHO")); tempInfo.setPiso(rs4.getString("PISO")); String charValueStr = ""; if (rs4.getString("NIVEL_SOCIOECONOMICO") != null) { charValueStr = rs4.getString("NIVEL_SOCIOECONOMICO"); } if (!charValueStr.equals("") && charValueStr != null) { tempInfo.setNivelSocioeconomico(charValueStr.charAt(0)); } tempInfo.setExpectativaEdadMin(rs4.getShort("EXPECTATIVA_EDAD_MIN")); tempInfo.setExpectativaGenero(rs4.getString("EXPECTATIVA_GENERO")); tempInfo.setOrigenHijos(rs4.getString("ORIGEN_HIJOS")); tempInfo.setPuedeViajar(rs4.getShort("PUEDE_VIAJAR")); tempInfo.setPredisposicionAp(rs4.getString("PREDISPOSICION_AP")); tempInfo.setCondicion(rs4.getString("CONDICION")); tempInfo.setAntecedenteFamilia(rs4.getString("ANTECEDENTE_FAMILIA")); tempInfo.setFechaAntecedenteFamilia(rs4.getDate("FECHA_ANTECEDENTE_FAMILIA")); tempInfo.setObservaciones(rs4.getString("OBSERVACIONES")); tempInfo.setNnaIncesto(rs4.getShort("NNA_INCESTO")); tempInfo.setNnaMental(rs4.getShort("NNA_MENTAL")); tempInfo.setNnaEpilepsia(rs4.getShort("NNA_EPILEPSIA")); tempInfo.setNnaAbuso(rs4.getShort("NNA_ABUSO")); tempInfo.setNnaSifilis(rs4.getShort("NNA_SIFILIS")); tempInfo.setNnaSeguiMedico(rs4.getShort("NNA_SEGUI_MEDICO")); tempInfo.setNnaOperacion(rs4.getShort("NNA_OPERACION")); tempInfo.setNnaHiperactivo(rs4.getShort("NNA_HIPERACTIVO")); tempInfo.setNnaEspecial(rs4.getShort("NNA_ESPECIAL")); tempInfo.setNnaEnfermo(rs4.getShort("NNA_ENFERMO")); tempInfo.setNnaMayor(rs4.getShort("NNA_MAYOR")); tempInfo.setNnaAdolescente(rs4.getShort("NNA_ADOLESCENTE")); tempInfo.setNnaHermano(rs4.getShort("NNA_HERMANO")); tempInfo.setEstadoCivil(rs4.getString("ESTADO_CIVIL")); tempInfo.setFechaMatrimonio(rs4.getDate("FECHA_MATRIMONIO")); tempInfo.setTelefono(rs4.getString("TELEFONO")); tempInfo.setExpectativaEdadMax(rs4.getShort("EXPECTATIVA_EDAD_MAX")); tempInfo.setnHijos(rs4.getShort("NHIJOS")); Set<Adoptante> listadop = new HashSet<Adoptante>(); String query7 = "{call RENAD_ADOPTANTE(?,?)}"; CallableStatement statement7 = connection.prepareCall(query7); statement7.setLong(1, tempInfo.getIdinfoFamilia()); statement7.registerOutParameter(2, OracleTypes.CURSOR); statement7.execute(); ResultSet rs7 = (ResultSet) statement7.getObject(2); while (rs7.next()) { Adoptante tempAdoptante = new Adoptante(); tempAdoptante.setIdadoptante(rs7.getLong("IDADOPTANTE")); tempAdoptante.setInfoFamilia(tempInfo); tempAdoptante.setNombre(rs7.getString("NOMBRE")); tempAdoptante.setApellidoP(rs7.getString("APELLIDO_P")); tempAdoptante.setApellidoM(rs7.getString("APELLIDO_M")); String tempsexo = ""; tempsexo = rs7.getString("SEXO"); if (!rs7.wasNull()) { tempAdoptante.setSexo(tempsexo.charAt(0)); } tempAdoptante.setFechaNac(rs7.getDate("FECHA_NAC")); tempAdoptante.setLugarNac(rs7.getString("LUGAR_NAC")); tempAdoptante.setDepaNac(rs7.getString("DEPA_NAC")); tempAdoptante.setPaisNac(rs7.getString("PAIS_NAC")); String tempTipoDoc = ""; tempTipoDoc = rs7.getString("TIPO_DOC"); if (!rs7.wasNull()) { tempAdoptante.setTipoDoc(tempTipoDoc.charAt(0)); } tempAdoptante.setNDoc(rs7.getString("N_DOC")); tempAdoptante.setCelular(rs7.getString("CELULAR")); tempAdoptante.setCorreo(rs7.getString("CORREO")); tempAdoptante.setNivelInstruccion(rs7.getString("NIVEL_INSTRUCCION")); tempAdoptante.setCulminoNivel(rs7.getShort("CULMINO_NIVEL")); tempAdoptante.setProfesion(rs7.getString("PROFESION")); tempAdoptante.setTrabajadorDepend(rs7.getShort("TRABAJADOR_DEPEND")); tempAdoptante.setOcupActualDep(rs7.getString("OCUP_ACTUAL_DEP")); tempAdoptante.setCentroTrabajo(rs7.getString("CENTRO_TRABAJO")); tempAdoptante.setDireccionCentro(rs7.getString("DIRECCION_CENTRO")); tempAdoptante.setTelefonoCentro(rs7.getString("TELEFONO_CENTRO")); tempAdoptante.setIngresoDep(rs7.getLong("INGRESO_DEP")); tempAdoptante.setTrabajadorIndepend(rs7.getShort("TRABAJADOR_INDEPEND")); tempAdoptante.setOcupActualInd(rs7.getString("OCUP_ACTUAL_IND")); tempAdoptante.setIngresoIndep(rs7.getLong("INGRESO_INDEP")); tempAdoptante.setSeguroSalud(rs7.getShort("SEGURO_SALUD")); tempAdoptante.setTipoSeguro(rs7.getString("TIPO_SEGURO")); tempAdoptante.setSeguroVida(rs7.getShort("SEGURO_VIDA")); tempAdoptante.setSistPensiones(rs7.getShort("SIST_PENSIONES")); tempAdoptante.setSaludActual(rs7.getString("SALUD_ACTUAL")); listadop.add(tempAdoptante); } rs7.close(); statement7.close(); tempInfo.setAdoptantes(listadop); listaInf.add(tempInfo); } rs4.close(); statement4.close(); Entidad tempEnt = new Entidad(); String hql5 = "{call HE_GETENTIDAD_FAMILIA(?,?)}"; CallableStatement statement5 = connection.prepareCall(hql5); statement5.setLong(1, tempFam.getIdfamilia()); statement5.registerOutParameter(2, OracleTypes.CURSOR); statement5.execute(); ResultSet rs5 = (ResultSet) statement5.getObject(2); if (rs5.next()) { tempEnt.setIdentidad(rs5.getLong("IDENTIDAD")); tempEnt.setNombre(rs5.getString("NOMBRE")); } rs5.close(); statement5.close(); Set<Designacion> listaDesig = new HashSet<Designacion>(); String hql6 = "{call REPORTE_ULTDESIG(?,?)}"; CallableStatement statement6 = connection.prepareCall(hql6); statement6.setLong(1, expFamilia.getIdexpedienteFamilia()); statement6.registerOutParameter(2, OracleTypes.CURSOR); statement6.execute(); ResultSet rs6 = (ResultSet) statement6.getObject(2); if (rs6.next()) { Designacion tempDesig = new Designacion(); tempDesig.setIddesignacion(rs6.getLong("IDDESIGNACION")); tempDesig.setNDesignacion(rs6.getString("N_DESIGNACION")); tempDesig.setPrioridad(rs6.getLong("PRIORIDAD")); tempDesig.setFechaPropuesta(rs6.getDate("FECHA_PROPUESTA")); tempDesig.setFechaConsejo(rs6.getDate("FECHA_CONSEJO")); tempDesig.setAceptacionConsejo(rs6.getShort("ACEPTACION_CONSEJO")); tempDesig.setTipoPropuesta(rs6.getString("TIPO_PROPUESTA")); listaDesig.add(tempDesig); } rs6.close(); statement6.close(); tempFam.setEntidad(tempEnt); tempFam.setInfoFamilias(listaInf); expFamilia.setDesignacions(listaDesig); expFamilia.setFamilia(tempFam); expFamilia.setUnidad(TempUn); expFamilia.setEvaluacions(listaEv); } rs.close(); statement.close(); } }; session.doWork(work); return expFamilia; }
From source file:com.nec.crud.hibernate.HibernateSessionManager.java
License:Open Source License
/** * Ask the Hibernate session to execute the unit of work * //from w w w.ja va 2 s.c om * @param session * @return */ private static boolean isConnected(Session session) { try { session.doWork(new PingConnectionWork()); } catch (Exception ex) { logger.warn(ex.getMessage(), ex); // FALSE if connection is closed return false; } return true; }
From source file:com.nec.crud.hibernate4.HibernateSessionManager.java
License:Open Source License
/** * Ask the Hibernate session to execute the unit of work * // w w w .j av a 2 s . com * @param session * @return */ private static boolean isConnected(Session session) { try { // We're having some difficult to diagnose connection issues at the moment. // To experiment lets test the connection when opened, if it fails do a rollback session.doWork(new PingConnectionWork()); } catch (Exception ex) { LOGGER.warn(ex.getMessage(), ex); // Connection test failed return false; } return true; }
From source file:com.netsteadfast.greenstep.base.sys.HibernateExtendedJpaDialect.java
License:Apache License
@Override public Object beginTransaction(final EntityManager entityManager, final TransactionDefinition definition) throws PersistenceException, SQLException, TransactionException { Session session = (Session) entityManager.getDelegate(); if (definition.getTimeout() != TransactionDefinition.TIMEOUT_DEFAULT) { getSession(entityManager).getTransaction().setTimeout(definition.getTimeout()); }/*from w w w . ja v a2s .c o m*/ entityManager.getTransaction().begin(); logger.debug("Transaction started"); session.doWork(new Work() { @Override public void execute(Connection connection) throws SQLException { logger.debug("The connection instance is " + connection.toString()); logger.debug("The isolation level of the connection is " + connection.getTransactionIsolation() + " and the isolation level set on the transaction is " + definition.getIsolationLevel()); DataSourceUtils.prepareConnectionForTransaction(connection, definition); } }); return prepareTransaction(entityManager, definition.isReadOnly(), definition.getName()); }