List of usage examples for org.hibernate Query setLong
@Deprecated @SuppressWarnings("unchecked") default Query<R> setLong(String name, long val)
From source file:com.mimp.hibernate.HiberMain.java
public ExpedienteFamilia getInformacionRegistro(long id) { Session session = sessionFactory.getCurrentSession(); session.beginTransaction();/*from w ww .ja va 2s . c om*/ ExpedienteFamilia expFamilia = new ExpedienteFamilia(); String hqlA = "FROM ExpedienteFamilia EF WHERE EF.id = :id"; Query queryA = session.createQuery(hqlA); queryA.setLong("id", id); Object queryResultA = queryA.uniqueResult(); expFamilia = (ExpedienteFamilia) queryResultA; Hibernate.initialize(expFamilia.getUnidad()); Hibernate.initialize(expFamilia.getFamilia().getEntidad()); return expFamilia; }
From source file:com.mimp.hibernate.HiberMain.java
public Sesion getInfoSesion(long id) { Session session = sessionFactory.getCurrentSession(); Sesion sesion = new Sesion(); session.beginTransaction();/* w ww . j a va 2 s .c om*/ String hql = "From Sesion S where S.id = :id"; Query query = session.createQuery(hql); query.setLong("id", id); Object queryResultU = query.uniqueResult(); sesion = (Sesion) queryResultU; return sesion; }
From source file:com.mimp.hibernate.HiberMain.java
public ArrayList<Reunion> getListaReunionesPorTurno(long idTurno) { Session session = sessionFactory.getCurrentSession(); session.beginTransaction();// ww w .j av a 2 s . c om String hql = "From Reunion R where R.turno2 = :id"; Query query = session.createQuery(hql); query.setLong("id", idTurno); List reuniones = query.list(); ArrayList<Reunion> allReuniones = new ArrayList(); for (Iterator iter = reuniones.iterator(); iter.hasNext();) { Reunion temp = (Reunion) iter.next(); allReuniones.add(temp); } return allReuniones; }
From source file:com.mimp.hibernate.HiberMain.java
public ArrayList<Evaluacion> getListaEvaluacionesPorExpediente(long idExp) { Session session = sessionFactory.getCurrentSession(); session.beginTransaction();/*from ww w. jav a 2 s .c o m*/ String hql = "From Evaluacion E where E.expedienteFamilia = :id ORDER BY E.idevaluacion DESC"; Query query = session.createQuery(hql); query.setLong("id", idExp); List evaluaciones = query.list(); ArrayList<Evaluacion> allEvaluaciones = new ArrayList(); for (Iterator iter = evaluaciones.iterator(); iter.hasNext();) { Evaluacion temp = (Evaluacion) iter.next(); Hibernate.initialize(temp.getResolucions()); allEvaluaciones.add(temp); } return allEvaluaciones; }
From source file:com.mimp.hibernate.HiberMain.java
public ArrayList<Designacion> getListaDesignacionesPorExpediente(long idExp) { Session session = sessionFactory.getCurrentSession(); session.beginTransaction();/*from ww w . ja v a2s .c om*/ String hql = "From Designacion D where D.expedienteFamilia = :id"; Query query = session.createQuery(hql); query.setLong("id", idExp); List designaciones = query.list(); ArrayList<Designacion> allDesignaciones = new ArrayList(); for (Iterator iter = designaciones.iterator(); iter.hasNext();) { Designacion temp = (Designacion) iter.next(); if (temp.getAceptacionConsejo() == 2) { Hibernate.initialize(temp.getNna().getExpedienteNnas()); Hibernate.initialize(temp.getNna().getJuzgado()); Hibernate.initialize(temp.getNna().getCar()); } else { Hibernate.initialize(temp.getNna()); } allDesignaciones.add(temp); } return allDesignaciones; }
From source file:com.mimp.hibernate.HiberMain.java
public ArrayList<Designacion> getListaNnaAdoptantesAdopcion(long idExp) { Session session = sessionFactory.getCurrentSession(); session.beginTransaction();//from www.j a v a 2s .co m String hql = "From Designacion D where D.expedienteFamilia = :id"; Query query = session.createQuery(hql); query.setLong("id", idExp); List designaciones = query.list(); ArrayList<Designacion> allDesignaciones = new ArrayList(); for (Iterator iter = designaciones.iterator(); iter.hasNext();) { Designacion temp = (Designacion) iter.next(); if (temp.getAceptacionConsejo() == 4) { Hibernate.initialize(temp.getNna()); } allDesignaciones.add(temp); } return allDesignaciones; }
From source file:com.mimp.hibernate.HiberMain.java
public ArrayList<EstudioCaso> getListaEstudiosPorExpediente(long idExp) { Session session = sessionFactory.getCurrentSession(); session.beginTransaction();/* ww w . j a va 2 s . c o m*/ String hql = "From EstudioCaso E where E.expedienteFamilia = :id"; Query query = session.createQuery(hql); query.setLong("id", idExp); List estudios = query.list(); ArrayList<EstudioCaso> allEstudios = new ArrayList(); for (Iterator iter = estudios.iterator(); iter.hasNext();) { EstudioCaso temp = (EstudioCaso) iter.next(); Hibernate.initialize(temp.getNna().getExpedienteNnas()); allEstudios.add(temp); } return allEstudios; }
From source file:com.mimp.hibernate.HiberMain.java
public Evaluacion getEvaluacionJuntoPersonal(long id) { Session session = sessionFactory.getCurrentSession(); session.beginTransaction();/*w ww. j a va 2 s . c o m*/ Evaluacion tempEval = new Evaluacion(); String hqlA = "FROM Evaluacion E WHERE E.id = :id"; Query queryA = session.createQuery(hqlA); queryA.setLong("id", id); Object queryResultA = queryA.uniqueResult(); tempEval = (Evaluacion) queryResultA; Hibernate.initialize(tempEval.getPersonal()); return tempEval; }
From source file:com.mimp.hibernate.HiberMain.java
public ArrayList<Taller> listaTalleresProgramados(String ua) { Session session = sessionFactory.getCurrentSession(); session.beginTransaction();/* www .jav a2 s .com*/ final String uaN = ua; ArrayList<Taller> allTalleres = new ArrayList(); String hql = "FROM Taller T where T.tipoTaller = :tipo and T.unidad = :ua order by T.idtaller ASC"; Query query = session.createQuery(hql); query.setString("tipo", "preparacion"); query.setString("ua", ua); List talleres = query.list(); for (Iterator iter1 = talleres.iterator(); iter1.hasNext();) { Taller temp1 = (Taller) iter1.next(); String hql2 = "From Grupo G where G.taller = :idT order by G.idgrupo asc"; query = session.createQuery(hql2); query.setLong("idT", temp1.getIdtaller()); List listaGrupos = query.list(); Set<Grupo> allGrupos = new LinkedHashSet<>(); for (Iterator iter2 = listaGrupos.iterator(); iter2.hasNext();) { Grupo temp2 = (Grupo) iter2.next(); String hql3 = "From Turno2 T where T.grupo = :idG order by T.idturno2 asc"; query = session.createQuery(hql3); query.setLong("idG", temp2.getIdgrupo()); List listaT2 = query.list(); Set<Turno2> allTurno2 = new LinkedHashSet<>(); for (Iterator iter3 = listaT2.iterator(); iter3.hasNext();) { Turno2 temp3 = (Turno2) iter3.next(); String hql4 = "From Reunion R where R.turno2 = :idT order by R.fecha ASC"; query = session.createQuery(hql4); query.setLong("idT", temp3.getIdturno2()); List reuniones = query.list(); Set<Reunion> reunions = new LinkedHashSet<>(); for (Iterator iter4 = reuniones.iterator(); iter4.hasNext();) { Reunion reu = (Reunion) iter4.next(); reunions.add(reu); } temp3.setReunions(reunions); allTurno2.add(temp3); } temp2.setTurno2s(allTurno2); allGrupos.add(temp2); } temp1.setGrupos(allGrupos); allTalleres.add(temp1); } return allTalleres; // Session session = sessionFactory.getCurrentSession(); // // session.beginTransaction(); // // String hql = "FROM Taller T where T.unidad = :ua order by T.idtaller ASC"; // Query query = session.createQuery(hql); // query.setString("ua", ua); // List talleres = query.list(); // ArrayList<Taller> allTalleres = new ArrayList(); // for (Iterator iter = talleres.iterator(); iter.hasNext();) { // Taller temp = (Taller) iter.next(); // Hibernate.initialize(temp.getGrupos()); // Set<Grupo> grupos = new HashSet<Grupo>(0); // for (Grupo grp : temp.getGrupos()) { // Hibernate.initialize(grp.getTurno2s()); // Set<Turno2> turno2s = new HashSet<Turno2>(0); // for (Turno2 trn : grp.getTurno2s()) { // Hibernate.initialize(trn.getReunions()); // turno2s.add(trn); // } // grp.setTurno2s(turno2s); // grupos.add(grp); // } // temp.setGrupos(grupos); // allTalleres.add(temp); // } }
From source file:com.mimp.hibernate.HiberMain.java
public ArrayList<Designacion> getListaDesignacionesAdoptantesExtranjero(long idExp) { Session session = sessionFactory.getCurrentSession(); session.beginTransaction();/* w w w . j a v a 2s. c om*/ String hql = "From Designacion D where D.expedienteFamilia = :idExp and D.aceptacionConsejo = :aceptacion and D.tipoPropuesta = :tipo order by D.fechaConsejo DESC"; Query query = session.createQuery(hql); query.setLong("idExp", idExp); query.setShort("aceptacion", Short.parseShort("4")); query.setString("tipo", "extranjero"); List designaciones = query.list(); ArrayList<Designacion> allDesignaciones = new ArrayList(); for (Iterator iter = designaciones.iterator(); iter.hasNext();) { Designacion temp = (Designacion) iter.next(); Hibernate.initialize(temp.getNna()); allDesignaciones.add(temp); } return allDesignaciones; }