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.HiberPersonal.java
public Personal getPersonal(long idPers) { Session session = sessionFactory.getCurrentSession(); Personal pers = new Personal(); session.beginTransaction();/* w w w . j a v a 2 s . c o m*/ String hqlU = "FROM Personal P WHERE P.id = :id"; Query queryU = session.createQuery(hqlU); queryU.setLong("id", idPers); Object queryResultU = queryU.uniqueResult(); pers = (Personal) queryResultU; Hibernate.initialize(pers.getUnidad()); return pers; }
From source file:com.mimp.hibernate.HiberPersonal.java
public Sesion getSesion(long id) { Session session = sessionFactory.getCurrentSession(); Sesion sesion = new Sesion(); session.beginTransaction();/*from w w w.j a va 2s . co m*/ 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; Hibernate.initialize(sesion.getTurnos()); return sesion; }
From source file:com.mimp.hibernate.HiberPersonal.java
public ArrayList<FormularioSesion> InscritosSesion(long idSesion) { Session session = sessionFactory.getCurrentSession(); session.beginTransaction();//from ww w .j a v a2 s.c o m String hql = "FROM FormularioSesion F where F.sesion = :id"; Query query = session.createQuery(hql); query.setLong("id", idSesion); List formularios = query.list(); ArrayList<FormularioSesion> allFormularios = new ArrayList(); for (Iterator iter = formularios.iterator(); iter.hasNext();) { FormularioSesion temp = (FormularioSesion) iter.next(); Hibernate.initialize(temp.getAsistentes()); Hibernate.initialize(temp.getAsistenciaFTs()); Hibernate.initialize(temp.getFamilia()); allFormularios.add(temp); } return allFormularios; }
From source file:com.mimp.hibernate.HiberPersonal.java
public ArrayList<Asistente> asistentePorFormulario(long idFormulario) { Session session = sessionFactory.getCurrentSession(); session.beginTransaction();/*from w w w . j a va 2 s .c o m*/ String hql = "FROM Asistente A where A.formularioSesion = :id"; Query query = session.createQuery(hql); query.setLong("id", idFormulario); List asistentes = query.list(); ArrayList<Asistente> allAsistentes = new ArrayList(); for (Iterator iter = asistentes.iterator(); iter.hasNext();) { Asistente temp = (Asistente) iter.next(); Hibernate.initialize(temp.getFormularioSesion()); allAsistentes.add(temp); } return allAsistentes; }
From source file:com.mimp.hibernate.HiberPersonal.java
public Taller getTaller(long id) { Session session = sessionFactory.getCurrentSession(); Taller taller = new Taller(); session.beginTransaction();//w w w . ja v a 2 s . c om String hql = "From Taller T where T.id = :id"; Query query = session.createQuery(hql); query.setLong("id", id); Object queryResult = query.uniqueResult(); taller = (Taller) queryResult; //Hibernate.initialize(taller.getGrupos()); String hql2 = "From Grupo G where G.taller = :idT order by G.idgrupo asc"; query = session.createQuery(hql2); query.setLong("idT", taller.getIdtaller()); List listaGrupos = query.list(); Set<Grupo> allGrupos = new LinkedHashSet<>(); for (Iterator iter = listaGrupos.iterator(); iter.hasNext();) { Grupo temp = (Grupo) iter.next(); Hibernate.initialize(temp.getTurno2s()); allGrupos.add(temp); } // for (Grupo grup : taller.getGrupos()) { // Hibernate.initialize(grup.getTurno2s()); // allGrupos.add(grup); // } taller.setGrupos(allGrupos); return taller; }
From source file:com.mimp.hibernate.HiberPersonal.java
public Grupo getGrupo(long id) { Session session = sessionFactory.getCurrentSession(); Grupo grp = new Grupo(); session.beginTransaction();//from w w w . java 2 s. c om String hql = "From Grupo G where G.id = :id"; Query query = session.createQuery(hql); query.setLong("id", id); Object queryResult = query.uniqueResult(); grp = (Grupo) queryResult; Hibernate.initialize(grp.getTaller()); String hql2 = "From Turno2 T where T.grupo = :idG order by T.idturno2 asc"; query = session.createQuery(hql2); query.setLong("idG", grp.getIdgrupo()); List listaT2 = query.list(); //Hibernate.initialize(grp.getTurno2s()); Set<Turno2> allTurno2 = new LinkedHashSet<>(); for (Iterator iter = listaT2.iterator(); iter.hasNext();) { Turno2 temp = (Turno2) iter.next(); Hibernate.initialize(temp.getReunions()); allTurno2.add(temp); } // for (Turno2 t2 : grp.getTurno2s()) { // Hibernate.initialize(t2.getReunions()); // allTurno2.add(t2); // } grp.setTurno2s(allTurno2); return grp; }
From source file:com.mimp.hibernate.HiberPersonal.java
public Turno2 getTurno2(long id) { Session session = sessionFactory.getCurrentSession(); Turno2 t2 = new Turno2(); session.beginTransaction();//from w ww . ja v a 2s .co m String hql = "From Turno2 T where T.id = :id"; Query query = session.createQuery(hql); query.setLong("id", id); Object queryResult = query.uniqueResult(); t2 = (Turno2) queryResult; //Hibernate.initialize(t2.getReunions()); String hql2 = "From Reunion R where R.turno2 = :idT order by R.fecha ASC"; query = session.createQuery(hql2); query.setLong("idT", t2.getIdturno2()); List reuniones = query.list(); Set<Reunion> reunions = new LinkedHashSet<>(); for (Iterator iter = reuniones.iterator(); iter.hasNext();) { Reunion reu = (Reunion) iter.next(); reunions.add(reu); } Hibernate.initialize(t2.getGrupo()); t2.setReunions(reunions); return t2; }
From source file:com.mimp.hibernate.HiberPersonal.java
public Reunion getReunion(long id) { Session session = sessionFactory.getCurrentSession(); Reunion reun = new Reunion(); session.beginTransaction();/*from w w w . j a va 2 s .co m*/ String hql = "From Reunion R where R.id = :id"; Query query = session.createQuery(hql); query.setLong("id", id); Object queryResult = query.uniqueResult(); reun = (Reunion) queryResult; Hibernate.initialize(reun.getAsistenciaFRs()); Hibernate.initialize(reun.getTurno2()); Turno2 temp = new Turno2(); temp = reun.getTurno2(); Hibernate.initialize(temp.getGrupo()); reun.setTurno2(temp); return reun; }
From source file:com.mimp.hibernate.HiberPersonal.java
public ArrayList<FormularioSesion> InscritosTaller(long idTaller) { Session session = sessionFactory.getCurrentSession(); session.beginTransaction();/*from ww w.j av a2s .c om*/ ArrayList<FormularioSesion> allFormularios = new ArrayList(); Taller tempTaller = new Taller(); String hql = "From Taller T where T.id = :id"; Query query = session.createQuery(hql); query.setLong("id", idTaller); Object queryResult = query.uniqueResult(); tempTaller = (Taller) queryResult; Hibernate.initialize(tempTaller.getGrupos()); for (Grupo grp : tempTaller.getGrupos()) { Hibernate.initialize(grp.getTurno2s()); for (Turno2 T2 : grp.getTurno2s()) { Hibernate.initialize(T2.getReunions()); for (Reunion reun : T2.getReunions()) { Hibernate.initialize(reun.getAsistenciaFRs()); for (AsistenciaFR afr : reun.getAsistenciaFRs()) { Hibernate.initialize(afr.getFamilia().getFormularioSesions()); for (FormularioSesion formularioSesion : afr.getFamilia().getFormularioSesions()) { Hibernate.initialize(formularioSesion.getAsistentes()); allFormularios.add(formularioSesion); } } } } } return allFormularios; }
From source file:com.mimp.hibernate.HiberPersonal.java
public ArrayList<FormularioSesion> formulariosReunion(long idReunion) { Session session = sessionFactory.getCurrentSession(); session.beginTransaction();//from w ww .ja v a 2 s.c om String hql = "FROM Reunion R where R.id = :id"; Query query = session.createQuery(hql); query.setLong("id", idReunion); Object queryResult = query.uniqueResult(); Reunion tempReun = (Reunion) queryResult; ArrayList<FormularioSesion> allFormularios = new ArrayList(); String hql2 = "FROM AsistenciaFR AFR where AFR.reunion = :id order by AFR.familia asc"; Query query2 = session.createQuery(hql2); query2.setLong("id", tempReun.getIdreunion()); List asistencias = query2.list(); Set<AsistenciaFR> asistenciaFRs = new LinkedHashSet<>(); for (Iterator iter2 = asistencias.iterator(); iter2.hasNext();) { AsistenciaFR temp2 = (AsistenciaFR) iter2.next(); asistenciaFRs.add(temp2); } //Hibernate.initialize(tempReun.getAsistenciaFRs()); tempReun.setAsistenciaFRs(asistenciaFRs); long idtemp = 0; for (AsistenciaFR afr : tempReun.getAsistenciaFRs()) { Hibernate.initialize(afr.getFamilia()); if (afr.getFamilia().getIdfamilia() != idtemp) { String hql3 = "FROM FormularioSesion F where F.familia = :id order by F.fechaSol DESC"; Query query3 = session.createQuery(hql3); query3.setLong("id", afr.getFamilia().getIdfamilia()); query3.setMaxResults(1); List resultados = query3.list(); for (Iterator iter3 = resultados.iterator(); iter3.hasNext();) { FormularioSesion temp3 = (FormularioSesion) iter3.next(); Hibernate.initialize(temp3.getAsistentes()); Hibernate.initialize(temp3.getFamilia().getAsistenciaFRs()); allFormularios.add(temp3); } idtemp = afr.getFamilia().getIdfamilia(); } } return allFormularios; }