Example usage for org.hibernate Query setInteger

List of usage examples for org.hibernate Query setInteger

Introduction

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

Prototype

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

Source Link

Document

Bind a named int-valued parameter.

Usage

From source file:celepsa.rrcc.da.DocumentoDA.java

public List<Tmadjunto> listarAdjuntos(Integer tdoc) throws Exception {
    try {//from   ww w . j  ava2 s.c o  m
        String sQuery = "FROM Tmadjunto where tmDocumento_id = :documentoId";
        logger.debug("listarAdjuntosPorDocumento");
        org.hibernate.Transaction tx = session.beginTransaction();
        Query query = session.createQuery(sQuery);
        query.setInteger("documentoId", tdoc);
        return query.list();
    } catch (NumberFormatException | HibernateException e) {
        logger.error(e.getMessage());
        throw e;
    }
}

From source file:celepsa.rrcc.da.DocumentoDA.java

public boolean eliminarDocumentoAdjunto(Tmadjunto objAdjunto, Tmdocumento objDocumento) throws Exception {
    String sQuery = "UPDATE Tmadjunto SET eliminado='1' WHERE id=:id and tmDocumento_id=:documentoId";

    try {/*w ww  . ja  v a 2s.co m*/
        org.hibernate.Transaction tx = session.beginTransaction();
        Query query = session.createQuery(sQuery);
        query.setInteger("id", objAdjunto.getTmadjuntoPK().getId());
        query.setInteger("documentoId", objDocumento.getId());
        return query.executeUpdate() > 0;
    } catch (NumberFormatException | HibernateException e) {
        logger.error(e.getMessage());
        throw e;
    }
}

From source file:celepsa.rrcc.da.PersonaDA.java

public List<Tmstakepersona> listarPersona(Integer tdoc) throws Exception {
    try {//from w ww .  j a v a2  s. c  o m
        String sQuery = "FROM Tmstakepersona WHERE est=0";
        if (tdoc != 0) {
            sQuery = "SELECT DISTINCT Tmstakepersona.id, CONCAT(Tmstakepersona.Nombre , ' ', Tmstakepersona.Apellido) as nombre FROM "
                    + "Tmstakepersona WHERE  Tmstakepersona.id NOT IN (SELECT Tmstakepersona.id  FROM "
                    + "Tmstakepersona, PersonaDocumento where Tmstakepersona.id=PersonaDocumento.Tmstakepersona_id and "
                    + " PersonaDocumento.tmDocumento_id = :documentoId)";
        }
        logger.debug("listarPersona: " + sQuery);
        org.hibernate.Transaction tx = session.beginTransaction();
        Query query = session.createQuery(sQuery);
        if (tdoc != 0) {
            query.setInteger("documentoId", tdoc);
        }
        logger.debug("listarPersona: End");
        return query.list();
    } catch (HibernateException e) {
        logger.error(e.getMessage());
        throw e;
    }
}

From source file:celepsa.rrcc.da.PersonaDA.java

public Tmstakepersona obtenerPersona(Tmstakepersona objPersona) throws Exception {

    try {/*from  w  w  w  .j  av a2  s  .c  o m*/
        String sQuery = "FROM Tmstakepersona WHERE id = :id ";
        org.hibernate.Transaction tx = session.beginTransaction();
        Query query = session.createQuery(sQuery);
        query.setInteger("id", objPersona.getId());
        return (Tmstakepersona) query.list().get(0);
    } catch (HibernateException e) {
        logger.error(e.getMessage());
        throw e;
    }
}

From source file:celepsa.rrcc.da.PersonaDA.java

public boolean eliminarPersona(Tmstakepersona objDocumento) throws Exception {

    try {//  ww w .j  ava  2s .co  m
        org.hibernate.Transaction tx = session.beginTransaction();
        Query query = session.createQuery("UPDATE Tmstakepersona SET est = :est WHERE id = :id ");
        query.setInteger("est", objDocumento.getEst());
        query.setInteger("id", objDocumento.getId());
        return query.executeUpdate() > 0;
    } catch (NumberFormatException | HibernateException e) {
        logger.error(e.getMessage());
        throw e;
    }

}

From source file:celepsa.rrcc.da.StakeholderDA.java

public List<Tmstakepersona> listarStakeholder(Integer tdoc) throws Exception {

    try {/* w w w.j  a  va2s  .  co m*/
        String sQuery = "FROM Tmstakepersona WHERE est=0";
        logger.debug("listarStakeholder: " + sQuery);
        if (tdoc != 0) {
            /*  sQuery="SELECT DISTINCT tmStakePersona.id, "
             + " CONCAT(tmStakePersona.Nombre , ' ', tmStakePersona.Apellido) as nombre FROM " +
             "tmStakePersona  WHERE  tmStakePersona.id NOT IN (SELECT tmStakePersona.id  FROM " +
             "tmStakePersona, PersonaDocumento where tmStakePersona.id=PersonaDocumento.tmStakePersona_id and " +
             " PersonaDocumento.tmDocumento_id =" + tdoc +")";*/
            sQuery = "FROM Tmstakepersona where id not in ( select t.tmStakePersonaid.id from Tmdocumento t where t.id=:documentoId )";
            logger.debug("listarStakeholder: " + sQuery);
        }
        logger.debug(sQuery);
        org.hibernate.Transaction tx = session.beginTransaction();
        Query query = session.createQuery(sQuery);
        if (tdoc != 0) {
            query.setInteger("documentoId", tdoc);
        }
        return query.list();
    } catch (NumberFormatException | HibernateException e) {
        logger.error(e.getMessage());
        throw e;
    }
}

From source file:chitchatserver.SentenceDAO.java

public static List<ChatPackage.Sentence> getSentences(int conversationId) {
    List<ChatPackage.Sentence> rs = null;
    Session session = HibernateUtil.getSessionFactory().openSession();
    try {//from www  .  j  ava  2s  .c  o m
        String hql = "from Sentence s where s.conversationId=:conversationId";
        Query query = session.createQuery(hql);
        query.setInteger("conversationId", conversationId);
        rs = query.list();
    } catch (Exception ex) {
        System.out.println("Error getting sentences: " + ex.getMessage());
    } finally {
        session.close();
    }
    return rs;
}

From source file:chitchatserver.UserConversationDAO.java

public static List<UserConversation> getUserConversation(int conversationId) {
    List<UserConversation> rs = null;
    Session session = HibernateUtil.getSessionFactory().openSession();
    try {/*from  ww  w  .java2s. c  o  m*/
        String hql = "from UserConversation u where u.conversationId=:convId";
        Query query = session.createQuery(hql);
        query.setInteger("convId", conversationId);
        rs = query.list();
    } catch (Exception ex) {
        System.out.println("Error getting UserConversation" + ex.getMessage());
    } finally {
        session.close();
    }
    return rs;
}

From source file:clases.cDN.java

public DocumentoNotificacion leer_cod(Integer codDocumentoNotificacion) {
    DocumentoNotificacion obj = null;//from  ww  w  .  ja v a2s .c o m
    Transaction trns = null;
    sesion = HibernateUtil.getSessionFactory().openSession();
    try {
        trns = sesion.beginTransaction();
        Query q = sesion
                .createQuery("from DocumentoNotificacion dn where dn.codDocumentoNotificacion = :param1");
        q.setInteger("param1", codDocumentoNotificacion);
        obj = (DocumentoNotificacion) q.uniqueResult();
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        sesion.flush();
        sesion.close();
    }
    return obj;
}

From source file:classe.MembreUtil.java

public Membre getClientId(int id) {
    Membre unMembre = null;/* ww  w.  ja v  a2  s  .  co  m*/
    List<Membre> listeClients = null;

    Transaction tx = null;
    this.session = HibernateUtil.getSessionFactory().openSession();

    try {
        tx = session.beginTransaction();

        // Liste de tous les livres
        Query mem = session.createQuery("from Membre where Idmembre=:id");
        mem.setInteger("id", id);
        listeClients = mem.list();
    } catch (Exception e) {
        e.printStackTrace();
    }

    this.session.close();
    if (listeClients.size() != 0) {
        return listeClients.get(0);
    } else {
        return null;
    }
}