Example usage for org.hibernate Query setLong

List of usage examples for org.hibernate Query setLong

Introduction

In this page you can find the example usage for org.hibernate Query setLong.

Prototype

@Deprecated
@SuppressWarnings("unchecked")
default Query<R> setLong(String name, long val) 

Source Link

Document

Bind a named long-valued parameter.

Usage

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

public Nna getNnaAdoptantesExtranjero(long id) {

    Session session = sessionFactory.getCurrentSession();
    session.beginTransaction();//from ww  w  .j a  va 2  s. c  o  m
    Nna tempNna = new Nna();

    String hqlA = "FROM Nna N WHERE N.idnna = :id";
    Query queryA = session.createQuery(hqlA);
    queryA.setLong("id", id);
    Object queryResultA = queryA.uniqueResult();

    tempNna = (Nna) queryResultA;
    return tempNna;

}

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

public Designacion getDesignacionAdoptantesExtranjero(long id) {

    Session session = sessionFactory.getCurrentSession();
    session.beginTransaction();// w w  w .  jav a  2s.  com
    Designacion tempDesig = new Designacion();

    String hqlA = "FROM Designacion D WHERE D.iddesignacion = :id";
    Query queryA = session.createQuery(hqlA);
    queryA.setLong("id", id);
    Object queryResultA = queryA.uniqueResult();

    tempDesig = (Designacion) queryResultA;
    Hibernate.initialize(tempDesig.getExpedienteFamilia());
    return tempDesig;

}

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

public Nna getTodosDatosNna(long id) {

    Session session = sessionFactory.getCurrentSession();
    session.beginTransaction();/*  www .  j a  v  a  2  s .  c  om*/
    Nna tempNna = new Nna();

    String hqlA = "FROM Nna N WHERE N.idnna = :id";
    Query queryA = session.createQuery(hqlA);
    queryA.setLong("id", id);
    Object queryResultA = queryA.uniqueResult();

    tempNna = (Nna) queryResultA;
    Hibernate.initialize(tempNna.getExpedienteNnas());
    Hibernate.initialize(tempNna.getDesignacions());
    return tempNna;

}

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

public EstudioCaso getEstudioCasoEspecifico(Long idNna, Long idExpFam, String orden) {

    Session session = sessionFactory.getCurrentSession();
    session.beginTransaction();//www  .  jav a2  s.  c o  m
    EstudioCaso tempEst = new EstudioCaso();

    String hqlA = "FROM EstudioCaso EC WHERE EC.nna = :idN and EC.expedienteFamilia = :idE and EC.orden = :idEst";
    Query queryA = session.createQuery(hqlA);
    queryA.setLong("idN", idNna);
    queryA.setLong("idE", idExpFam);
    queryA.setString("idEst", orden);
    Object queryResultA = queryA.uniqueResult();

    tempEst = (EstudioCaso) queryResultA;
    Hibernate.initialize(tempEst.getExpedienteFamilia());
    return tempEst;

}

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

public ArrayList<Familia> ListaFam(long idEnt) {

    Session session = sessionFactory.getCurrentSession();

    session.beginTransaction();//from  w w w . ja  v  a2s.  com

    String hql = "FROM Familia F WHERE F.entidad = :id";
    Query query = session.createQuery(hql);
    query.setLong("id", idEnt);
    List fam = query.list();
    ArrayList<Familia> allFam = new ArrayList();

    for (Iterator iter = fam.iterator(); iter.hasNext();) {
        Familia temp = (Familia) iter.next();
        Hibernate.initialize(temp.getEntidad());
        allFam.add(temp);
    }

    return allFam;
}

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

public ArrayList<Familia> ListaFamDeEnt(long idEnt) {

    Session session = sessionFactory.getCurrentSession();

    session.beginTransaction();//from   w w w  .  j  a va 2s.  co m

    String hql = "FROM Familia F WHERE F.entidad = :id";
    Query query = session.createQuery(hql);
    query.setLong("id", idEnt);
    List fam = query.list();
    ArrayList<Familia> allFam = new ArrayList();

    for (Iterator iter = fam.iterator(); iter.hasNext();) {
        Familia temp = (Familia) iter.next();
        Hibernate.initialize(temp.getEntidad());
        Hibernate.initialize(temp.getExpedienteFamilias());

        String hql2 = "FROM InfoFamilia IF WHERE IF.familia = :idFam order by IF.idinfoFamilia DESC";
        Query query2 = session.createQuery(hql2);
        query2.setLong("idFam", temp.getIdfamilia());
        query2.setMaxResults(1);
        List infoFam = query2.list();

        Set<InfoFamilia> infoFamilias = new HashSet<InfoFamilia>(0);
        for (Iterator iter2 = infoFam.iterator(); iter2.hasNext();) {
            InfoFamilia tempInf = (InfoFamilia) iter2.next();
            Hibernate.initialize(tempInf.getAdoptantes());
            infoFamilias.add(tempInf);
        }
        temp.setInfoFamilias(infoFamilias);
        allFam.add(temp);
    }

    return allFam;
}

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

public Adoptante AdopPorIdFamPorSex(long idInfo, String sexo) {

    Session session = sessionFactory.getCurrentSession();
    Adoptante AdopPorIdFamPorSex = new Adoptante();

    session.beginTransaction();//  w ww .  ja  v a  2 s .  co  m
    String hqlO = "FROM Adoptante A WHERE A.infoFamilia = :id and A.sexo = :sexo";
    Query queryO = session.createQuery(hqlO);
    queryO.setLong("id", idInfo);
    queryO.setString("sexo", sexo);
    Object queryResultA = queryO.uniqueResult();

    if (queryResultA != null) {
        AdopPorIdFamPorSex = (Adoptante) queryResultA;
        Hibernate.initialize(AdopPorIdFamPorSex.getInfoFamilia());
    }
    return AdopPorIdFamPorSex;
}

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

public InfoFamilia InfoFamilia(long idInfo) {

    Session session = sessionFactory.getCurrentSession();
    InfoFamilia InfoFamilia = new InfoFamilia();

    session.beginTransaction();/*from w w  w .  ja v a 2  s.c  om*/
    String hqlO = "FROM InfoFamilia I WHERE I.id = :id";
    Query queryO = session.createQuery(hqlO);
    queryO.setLong("id", idInfo);
    Object queryResultA = queryO.uniqueResult();

    InfoFamilia = (InfoFamilia) queryResultA;
    //Hibernate.initialize(LaAdop.getInfoFamilia());        
    return InfoFamilia;
}

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

public ExpedienteFamilia ExpPorIDFamilia(long idFam) {

    Session session = sessionFactory.getCurrentSession();
    ExpedienteFamilia expedienteFamilia = new ExpedienteFamilia();

    session.beginTransaction();//from w  w  w . j a va2 s .c  o  m
    String hqlO = "FROM ExpedienteFamilia E WHERE E.familia = :id";
    Query queryO = session.createQuery(hqlO);
    queryO.setLong("id", idFam);
    Object queryResultA = queryO.uniqueResult();

    expedienteFamilia = (ExpedienteFamilia) queryResultA;
    Hibernate.initialize(expedienteFamilia.getFamilia());
    Hibernate.initialize(expedienteFamilia.getUnidad().getNombre());
    Hibernate.initialize(expedienteFamilia.getFamilia().getEntidad().getNombre());
    Hibernate.initialize(expedienteFamilia.getEvaluacions());
    Hibernate.initialize(expedienteFamilia.getDesignacions());
    return expedienteFamilia;
}

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

public Familia FamiliaPorID(long idFam) {

    Session session = sessionFactory.getCurrentSession();
    Familia familia = new Familia();

    session.beginTransaction();// w w  w .  j  a v a2s  .c  o  m
    String hqlO = "FROM Familia F WHERE F.id = :id";
    Query queryO = session.createQuery(hqlO);
    queryO.setLong("id", idFam);
    Object queryResultA = queryO.uniqueResult();

    familia = (Familia) queryResultA;
    Hibernate.initialize(familia.getEntidad());
    Hibernate.initialize(familia.getExpedienteFamilias());

    return familia;
}