List of usage examples for org.hibernate Criteria uniqueResult
public Object uniqueResult() throws HibernateException;
From source file:br.com.crescer.aula4.mapeamentoBaseNunes.DAO.ProdutoMaterialDAO.java
@Override public ProdutoMaterial findById(Long id) { Criteria crit = session.createCriteria(ProdutoMaterial.class); crit.add(Restrictions.like("idProdutoMaterial", id)); return (ProdutoMaterial) (crit.uniqueResult()); }
From source file:br.com.danese.multitenancy.data.MemberRepository.java
License:Apache License
public Member findByEmail(String email) { Criteria criteria = session().createCriteria(Member.class); criteria.add(Restrictions.eq("email", email)); return (Member) criteria.uniqueResult(); }
From source file:br.com.estube.portalcommunication.persistence.Persistencia.java
public Object buscarObjeto(Class<?> tipo, List<Filtro> filtros) throws Exception { Criteria criteria = session.createCriteria(tipo); for (int index = 0; index < filtros.size(); index++) { criteria.add(Restrictions.eq(filtros.get(index).getCampo(), filtros.get(index).getValor())); }/* w ww. j a v a2 s . c om*/ Object objectoDesconhecido = criteria.uniqueResult(); return objectoDesconhecido; }
From source file:br.com.finance.dao.CredorDAO.java
public Credores getCredorById(Long CredorID) { Session sessao = getSession();/*from w ww. j av a 2s . co m*/ Credores credor = null; try { Criteria cr = sessao.createCriteria(Credores.class); cr.add(Restrictions.eq("idcredor", CredorID)); credor = new Credores(); credor = (Credores) cr.uniqueResult(); } catch (Exception e) { e.printStackTrace(); credor = null; } finally { sessao.close(); } return credor; }
From source file:br.com.financeiro.dao.ContaDAOHibernate.java
@Override public Conta buscarFavorita(Usuario usuario) { Criteria criteria = this.session.createCriteria(Conta.class); criteria.add(Restrictions.eq("usuario", usuario)); criteria.add(Restrictions.eq("favorita", true)); return (Conta) criteria.uniqueResult(); }
From source file:br.com.hrstatus.dao.impl.BancoDadosDAO.java
License:Open Source License
public int insert_dataBase(BancoDados dataBase) { log.fine("[ " + userInfo.getLoggedUsername() + " ] insert_dataBase(BancoDados dataBase)[" + dataBase.getHostname() + "]"); log.fine("Server: " + dataBase.getHostname()); log.fine("IP: " + dataBase.getIp()); log.fine("User: " + dataBase.getUser()); log.fine("Pass: gotcha!"); log.fine("Port: " + dataBase.getPort()); log.fine("VENDOR: " + dataBase.getVendor()); log.fine("Query: " + dataBase.getQueryDate()); try {/*from w w w .j a va2 s. com*/ final Criteria hostname = session().createCriteria(BancoDados.class) .add(Restrictions.eq("hostname", new String(dataBase.getHostname()))) .setProjection(Projections.property("hostname")); if (hostname.uniqueResult() == null) { log.info("[ " + userInfo.getLoggedUsername() + " ] insert_dataBase -> Database server " + dataBase.getHostname() + " not found."); log.info("[ " + userInfo.getLoggedUsername() + " ] insert_dataBase -> Saving data"); session().save(dataBase); return 0; } else { log.info("[ " + userInfo.getLoggedUsername() + " ] insert_dataBase -> Database server " + dataBase.getHostname() + " already exists, ignoring."); return 1; } } catch (Exception e) { log.severe("[ " + userInfo.getLoggedUsername() + " ] insert_dataBase -> Errorr: " + e); return 1; } }
From source file:br.com.hrstatus.dao.impl.BancoDadosDAO.java
License:Open Source License
public int countMysql() { log.fine("[ " + userInfo.getLoggedUsername() + " ] countMysql()"); final Criteria criteria = session().createCriteria(BancoDados.class); criteria.add(Restrictions.eq("vendor", "MYSQL")); criteria.setProjection(Projections.rowCount()); final int count = ((Long) criteria.uniqueResult()).intValue(); log.fine("[ " + userInfo.getLoggedUsername() + " ] countMysql() -> Found " + count + " Mysql Databases."); return count; }
From source file:br.com.hrstatus.dao.impl.BancoDadosDAO.java
License:Open Source License
public int countOracle() { log.fine("[ " + userInfo.getLoggedUsername() + " ] countOracle()"); final Criteria criteria = session().createCriteria(BancoDados.class); criteria.add(Restrictions.eq("vendor", "ORACLE")); criteria.setProjection(Projections.rowCount()); final int count = ((Long) criteria.uniqueResult()).intValue(); log.fine(//from w w w. j ava 2 s.co m "[ " + userInfo.getLoggedUsername() + " ] countOracle() -> Found " + count + " Oracle Databases.."); return count; }
From source file:br.com.hrstatus.dao.impl.BancoDadosDAO.java
License:Open Source License
public int countPostgre() { log.fine("[ " + userInfo.getLoggedUsername() + " ] countPostgre()"); final Criteria criteria = session().createCriteria(BancoDados.class); criteria.add(Restrictions.eq("vendor", "POSTGRESQL")); criteria.setProjection(Projections.rowCount()); final int count = ((Long) criteria.uniqueResult()).intValue(); log.fine("[ " + userInfo.getLoggedUsername() + " ] countPostgre() -> Found " + count + " Postgre Databases."); return count; }
From source file:br.com.hrstatus.dao.impl.BancoDadosDAO.java
License:Open Source License
public int countSqlServer() { log.fine("[ " + userInfo.getLoggedUsername() + " ] countSqlServer()"); final Criteria criteria = session().createCriteria(BancoDados.class); criteria.add(Restrictions.eq("vendor", "SQLSERVER")); criteria.setProjection(Projections.rowCount()); final int count = ((Long) criteria.uniqueResult()).intValue(); log.fine("[ " + userInfo.getLoggedUsername() + " ] countSqlServer() -> Found " + count + " SqlServer Databases."); return count; }