List of usage examples for org.hibernate Criteria uniqueResult
public Object uniqueResult() throws HibernateException;
From source file:br.com.chamado.dao.DaoGenerico.java
public Object carregarUm(int id, Class<?> classe) { Session session = hibernateConfiguracao.openSession(); Transaction transaction = session.beginTransaction(); Criteria criteria = session.createCriteria(classe); criteria.add(Restrictions.eq("id", id)); Object obj = criteria.uniqueResult(); transaction.commit();//ww w .j a v a2 s . com return obj; }
From source file:br.com.chamado.dao.DaoGenerico.java
public boolean veriricar(String campo, String valor, Class<?> classe) { Session session = hibernateConfiguracao.openSession(); Transaction transaction = session.beginTransaction(); Criteria criteria = session.createCriteria(classe); criteria.add(Restrictions.eq(campo, valor)); Object obj = criteria.uniqueResult(); transaction.commit();// w w w . ja v a2 s.c o m if (obj == null) { return true; } else { return false; } }
From source file:br.com.chamados.control.DAO.java
public T queryById(String campo, Serializable valor, Class clazz) { openSession();/*from www . j a va2s . com*/ Criteria criteria = session.createCriteria(clazz); criteria.add(Restrictions.eq(campo, valor)); return (T) criteria.uniqueResult(); }
From source file:br.com.controlehoras.dao.EscalaDao.java
public Boolean pesquisarData(Date data) { sessao = (Session) HibernateUtil.getSessionFactory().openSession(); try {//from w ww.ja va 2 s . c o m Criteria criteria = sessao.createCriteria(Escala.class); criteria.add(Restrictions.eq("data", data)); Escala escala = (Escala) criteria.uniqueResult(); if (escala == null) { return false; } else { return true; } } catch (Exception e) { e.printStackTrace(); return false; } finally { sessao.close(); } }
From source file:br.com.crescer.aula4.mapeamentoBaseNunes.DAO.CidadeDAO.java
@Override public Cidade findById(Long id) { Criteria crit = session.createCriteria(Cidade.class); crit.add(Restrictions.like("idCidade", id)); return (Cidade) (crit.uniqueResult()); }
From source file:br.com.crescer.aula4.mapeamentoBaseNunes.DAO.ClienteDAO.java
@Override public Cliente findById(Long id) { Criteria crit = session.createCriteria(Cliente.class); crit.add(Restrictions.like("idCliente", id)); return (Cliente) (crit.uniqueResult()); }
From source file:br.com.crescer.aula4.mapeamentoBaseNunes.DAO.MaterialDAO.java
@Override public Material findById(Long id) { Criteria crit = session.createCriteria(Material.class); crit.add(Restrictions.like("idMaterial", id)); return (Material) (crit.uniqueResult()); }
From source file:br.com.crescer.aula4.mapeamentoBaseNunes.DAO.PedidoDAO.java
@Override public Pedido findById(Long id) { Criteria crit = session.createCriteria(Pedido.class); crit.add(Restrictions.like("idPedido", id)); return (Pedido) (crit.uniqueResult()); }
From source file:br.com.crescer.aula4.mapeamentoBaseNunes.DAO.PedidoItemDAO.java
@Override public PedidoItem findById(Long id) { Criteria crit = session.createCriteria(PedidoItem.class); crit.add(Restrictions.like("idPedidoItem", id)); return (PedidoItem) (crit.uniqueResult()); }
From source file:br.com.crescer.aula4.mapeamentoBaseNunes.DAO.ProdutoDAO.java
@Override public Produto findById(Long id) { Criteria crit = session.createCriteria(Produto.class); crit.add(Restrictions.like("idProduto", id)); return (Produto) (crit.uniqueResult()); }