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:cd_modelos_dao.ComprasDAO.java

public void eliminarCompra(int id) {
    SessionFactory sf = HibernateUtil.getSessionFactory();
    Transaction t = null;//from   w ww . jav a 2 s  .  c  o m
    Session s = sf.openSession();
    t = s.beginTransaction();
    Query q = s.createQuery("delete from ComprasPlanta where id = :id");
    q.setInteger("id", id);
    q.executeUpdate();
    t.commit();
    s.close();
}

From source file:cd_modelos_dao.PlantasDAO.java

public void eliminarPlanta(int id) {
    SessionFactory sf = HibernateUtil.getSessionFactory();
    Session s = sf.openSession();/*from w  w  w  .j a v  a 2  s .c  om*/
    Transaction t = s.beginTransaction();
    Query q = s.createQuery("delete from Plantas where id = :id");
    q.setInteger("id", id);
    q.executeUpdate();
    t.commit();
    s.close();
}

From source file:cd_modelos_dao.ServiciosDAO.java

public void eliminarServicio(int id) {
    List<Servicios> lista = new LinkedList<>();
    SessionFactory sf = HibernateUtil.getSessionFactory();
    Session s = sf.openSession();/*from   w  ww .  ja v a2s.  c o  m*/
    Query q = s.createQuery("delete from Servicios where id = :id");
    q.setInteger("id", id);
    q.executeUpdate();
    s.close();

    //        SessionFactory sf = HibernateUtil.getSessionFactory();
    //        Session s = sf.openSession();
    //        Servicios ser = consultarServicioPorId(id);
    //        System.out.println("el servicio es " + ser.getNombre());
    //        System.out.println("el servicio es " + ser.getId());
    //        s.delete(ser);
    //        s.close();
}

From source file:cd_modelos_dao.VentasDAO.java

public void eliminarVenta(int id) {
    SessionFactory sf = HibernateUtil.getSessionFactory();
    Transaction t = null;/*ww w .j  a  v  a 2 s  .c  om*/
    Session s = sf.openSession();
    t = s.beginTransaction();
    Query q = s.createQuery("delete from VentasPlanta where id = :id");
    q.setInteger("id", id);
    q.executeUpdate();
    t.commit();
    s.close();
}

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

public List<Tmstakeagrupacion> listarAgrupacion(Integer tdoc) throws Exception {

    logger.debug("listarAgrupacion");
    try {/*from w  w w  .  j a v a 2  s  . c om*/
        String sQuery = "FROM Tmstakeagrupacion WHERE est=0";
        if (tdoc != 0) {
            sQuery = "SELECT DISTINCT tmStakeAgrupacion.id, CONCAT(tmStakeAgrupacion.Nombre , ' ', tmStakeAgrupacion.Apellido) as nombre FROM "
                    + "tmStakeAgrupacion WHERE  tmStakeAgrupacion.id NOT IN (SELECT tmStakeAgrupacion.id  FROM "
                    + "tmStakeAgrupacion, AgrupacionDocumento where tmStakeAgrupacion.id=AgrupacionDocumento.tmStakeAgrupacion_id and "
                    + " AgrupacionDocumento.tmDocumento_id =:documentoId)";
        }
        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:celepsa.rrcc.da.AgrupacionDA.java

public Tmstakeagrupacion obtenerAgrupacion(Tmstakeagrupacion objAgrupacion) throws Exception {

    logger.debug("obtenerAgrupacion hib");
    try {//from   ww w  .j a v  a2 s .  c  om
        org.hibernate.Transaction tx = session.beginTransaction();
        Query query = session.createQuery("from Tmstakeagrupacion where id = :id ");
        query.setInteger("id", objAgrupacion.getId());
        return (Tmstakeagrupacion) query.list().get(0);

    } catch (NumberFormatException | HibernateException e) {
        logger.error(e.getMessage());
        throw e;
    }
}

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

public void eliminarAgrupacion(Tmstakeagrupacion objAgrupacion) throws Exception {
    logger.debug("eliminarAgrupacion id=" + objAgrupacion.getId());
    String squery = " update Tmstakeagrupacion set est='2' WHERE id = :id ";

    try {/*from   w ww  .ja v a 2s .  c  o m*/
        org.hibernate.Transaction tx = session.beginTransaction();
        Query query = session.createQuery(squery);
        query.setInteger("id", objAgrupacion.getId());
        query.executeUpdate();
        tx.commit();
    } catch (NumberFormatException | HibernateException e) {
        logger.error(e.getMessage());
        throw e;
    }
}

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

public List<Tmdocumento> listarDocumentos(Integer tdoc) throws Exception {
    try {/*from w ww . j  a  v  a 2 s  .com*/
        logger.debug("listarDocumentos");
        String sQuery = "from Tmdocumento where  eliminado='0'";
        if (tdoc != 0) {
            sQuery = "from Tmdocumento where tmTipoDocumentoid.id = :documentoId OR tmTipoDocumentoid.id=0  and eliminado='0' ";
        }
        org.hibernate.Transaction tx = session.beginTransaction();
        Query query = session.createQuery(sQuery);
        if (tdoc != 0)
            query.setInteger("documentoId", tdoc);
        return query.list();

    } catch (HibernateException e) {
        logger.error(e.getMessage());

        e.printStackTrace();
        throw e;
    }
}

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

public Tmdocumento obtenerDocumento(Tmdocumento objDocumento) throws Exception {
    try {//from  w  w  w .j  av a2 s  . c om
        org.hibernate.Transaction tx = session.beginTransaction();
        Query query = session.createQuery("from Tmdocumento where id = :id ");
        query.setInteger("id", objDocumento.getId());
        return (Tmdocumento) query.list().get(0);
    } catch (NumberFormatException | HibernateException e) {
        logger.error(e.getMessage());
        e.printStackTrace();
        throw e;
    }
}

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

public boolean eliminarDocumento(Tmdocumento objDocumento) throws Exception {
    // eliminar con hibernate 
    try {// w w w. j a va2 s .  co m
        Query query = session.createQuery(" update Tmdocumento set eliminado= :eliminado where id = :id ");
        query.setCharacter("eliminado", objDocumento.getEliminado());
        query.setInteger("id", objDocumento.getId());
        return query.executeUpdate() > 0;
    } catch (NumberFormatException | HibernateException e) {
        logger.error(e.getMessage());
        e.printStackTrace();
        throw e;
    }
}