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:com.hasz.dao.StatusReservaDAO.java

public static StatusReserva buscaStatusReservaById(int idStatusReserva) {
    Session sessao = HibernateUtil.getSession();
    StatusReserva retorno = null;//w ww  . j  a v a2 s.co  m
    try {
        Query select = sessao.createQuery("from StatusReserva where idStatusReserva = :idStatusReserva");
        select.setInteger("idStatusReserva", idStatusReserva);
        List<StatusReserva> status = select.list();
        if (status.size() == 1)
            retorno = status.get(0);
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        sessao.close();
        return retorno;
    }
}

From source file:com.hibernate.dao.AutomovilDAO.java

public Automovil buscaAutomovil(int idAutomovil) {
    Automovil automovil = null;//from w w  w . j  a  v a  2 s  . c o  m
    Transaction trns = null;
    Session session = HibernateUtil.getSessionFactory().openSession();
    try {
        trns = session.beginTransaction();
        String queryString = "from Automovil where id = :id";
        Query query = session.createQuery(queryString);
        query.setInteger("id", idAutomovil);
        automovil = (Automovil) query.uniqueResult();
    } catch (RuntimeException e) {
        e.printStackTrace();
    } finally {
        session.flush();
        session.close();
    }
    return automovil;
}

From source file:com.hibernate.dao.ClienteDAO.java

public Cliente buscaCliente(int idCliente) {
    Cliente cliente = null;/*from ww w  .j av  a2s .co  m*/
    Transaction trns = null;
    Session session = HibernateUtil.getSessionFactory().openSession();
    try {
        trns = session.beginTransaction();
        String queryString = "from Cliente where id = :id";
        Query query = session.createQuery(queryString);
        query.setInteger("id", idCliente);
        cliente = (Cliente) query.uniqueResult();
    } catch (RuntimeException e) {
        e.printStackTrace();
    } finally {
        session.flush();
        session.close();
    }
    return cliente;
}

From source file:com.hibernate.dao.DireccionDAO.java

public Direccion buscaPedido(int idDireccion) {
    Direccion direccion = null;//from  w ww .  j a va2s .c  o m
    Transaction trns = null;
    Session session = HibernateUtil.getSessionFactory().openSession();
    try {
        trns = session.beginTransaction();
        String queryString = "from Direccion where id = :id";
        Query query = session.createQuery(queryString);
        query.setInteger("id", idDireccion);
        direccion = (Direccion) query.uniqueResult();
    } catch (RuntimeException e) {
        e.printStackTrace();
    } finally {
        session.flush();
        session.close();
    }
    return direccion;
}

From source file:com.hibernate.dao.PedidoDAO.java

public Pedido buscaPedido(int idPedido) {
    Pedido reparacion = null;/*from   w  ww .j  a v a2  s . co m*/
    Transaction trns = null;
    Session session = HibernateUtil.getSessionFactory().openSession();
    try {
        trns = session.beginTransaction();
        String queryString = "from Reparacion where id = :id";
        Query query = session.createQuery(queryString);
        query.setInteger("id", idPedido);
        reparacion = (Pedido) query.uniqueResult();
    } catch (RuntimeException e) {
        e.printStackTrace();
    } finally {
        session.flush();
        session.close();
    }
    return reparacion;
}

From source file:com.hibernate.dao.ProvedorDAO.java

public Provedor buscaProvedor(int idProvedor) {
    Provedor provedor = null;/*ww w. j av a 2 s.  c  o  m*/
    Transaction trns = null;
    Session session = HibernateUtil.getSessionFactory().openSession();
    try {
        trns = session.beginTransaction();
        String queryString = "from Provedor where id = :id";
        Query query = session.createQuery(queryString);
        query.setInteger("id", idProvedor);
        provedor = (Provedor) query.uniqueResult();
    } catch (RuntimeException e) {
        e.printStackTrace();
    } finally {
        session.flush();
        session.close();
    }
    return provedor;
}

From source file:com.hibernate.dao.RefaccionDAO.java

public Refaccion buscaProvedor(int idProvedor) {
    Refaccion provedor = null;/*from w w w  .j  a v a 2  s.co m*/
    Transaction trns = null;
    Session session = HibernateUtil.getSessionFactory().openSession();
    try {
        trns = session.beginTransaction();
        String queryString = "from Refaccion where id = :id";
        Query query = session.createQuery(queryString);
        query.setInteger("id", idProvedor);
        provedor = (Refaccion) query.uniqueResult();
    } catch (RuntimeException e) {
        e.printStackTrace();
    } finally {
        session.flush();
        session.close();
    }
    return provedor;
}

From source file:com.hibernate.dao.ReparaccionDAO.java

public Reparacion buscaProvedor(int idReparacion) {
    Reparacion reparacion = null;/*from   w w  w  .  ja  v  a  2s.  c om*/
    Transaction trns = null;
    Session session = HibernateUtil.getSessionFactory().openSession();
    try {
        trns = session.beginTransaction();
        String queryString = "from Reparacion where id = :id";
        Query query = session.createQuery(queryString);
        query.setInteger("id", idReparacion);
        reparacion = (Reparacion) query.uniqueResult();
    } catch (RuntimeException e) {
        e.printStackTrace();
    } finally {
        session.flush();
        session.close();
    }
    return reparacion;
}

From source file:com.hibernate.dao.ServicioDAO.java

public Servicio buscaServicio(int idServicio) {
    Servicio reparacion = null;/*from  ww w  . j a  v  a  2  s .  c  om*/
    Transaction trns = null;
    Session session = HibernateUtil.getSessionFactory().openSession();
    try {
        trns = session.beginTransaction();
        String queryString = "from Reparacion where id = :id";
        Query query = session.createQuery(queryString);
        query.setInteger("id", idServicio);
        reparacion = (Servicio) query.uniqueResult();
    } catch (RuntimeException e) {
        e.printStackTrace();
    } finally {
        session.flush();
        session.close();
    }
    return reparacion;
}

From source file:com.hibernate.dao.TelClienteDAO.java

public TelCliente buscaTelProvedor(int idTelefono) {
    TelCliente telefono = null;//from w ww .j  a va 2 s  . c o  m
    Transaction trns = null;
    Session session = HibernateUtil.getSessionFactory().openSession();
    try {
        trns = session.beginTransaction();
        String queryString = "from Telefono where id = :id";
        Query query = session.createQuery(queryString);
        query.setInteger("id", idTelefono);
        telefono = (TelCliente) query.uniqueResult();
    } catch (RuntimeException e) {
        e.printStackTrace();
    } finally {
        session.flush();
        session.close();
    }
    return telefono;
}