List of usage examples for org.hibernate Criteria uniqueResult
public Object uniqueResult() throws HibernateException;
From source file:br.com.hrstatus.dao.impl.ServersDAO.java
License:Open Source License
public Servidores getServerByID(int id) { log.fine("[ " + userInfo.getLoggedUsername() + " ] getServerByID(int " + id + ")"); final Criteria criteria = session().createCriteria(Servidores.class); criteria.add(Restrictions.eq("id", id)); criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); return (Servidores) criteria.uniqueResult(); }
From source file:br.com.hrstatus.dao.impl.ServersDAO.java
License:Open Source License
public int countWindows() { log.info("[ " + userInfo.getLoggedUsername() + " ] countWindows()"); final Criteria criteria = session().createCriteria(Servidores.class); criteria.add(Restrictions.eq("SO", "WINDOWS")); criteria.setProjection(Projections.rowCount()); final int count = ((Long) criteria.uniqueResult()).intValue(); log.fine("[ " + userInfo.getLoggedUsername() + " ] countWindows() -> Found " + count + " servers."); return count; }
From source file:br.com.hrstatus.dao.impl.ServersDAO.java
License:Open Source License
public int countUnix() { log.info("[ " + userInfo.getLoggedUsername() + " ] countUnix()"); final Criteria criteria = session().createCriteria(Servidores.class); criteria.add(Restrictions.eq("SO", "UNIX")); criteria.setProjection(Projections.rowCount()); final int count = ((Long) criteria.uniqueResult()).intValue(); log.fine("[ " + userInfo.getLoggedUsername() + " ] countUnix() -> Found " + count + " servers."); return count; }
From source file:br.com.hrstatus.dao.impl.ServersDAO.java
License:Open Source License
public int countAllServers() { log.info("[ " + userInfo.getLoggedUsername() + " ] countAllServers()"); final Criteria criteria = session().createCriteria(Servidores.class); criteria.setProjection(Projections.rowCount()); final int count = ((Long) criteria.uniqueResult()).intValue(); log.fine("[ " + userInfo.getLoggedUsername() + " ] countAllServers() -> Found " + count + " servers."); return count; }
From source file:br.com.hrstatus.dao.impl.ServersDAO.java
License:Open Source License
public int countServersOK() { log.fine("[ " + userInfo.getLoggedUsername() + " ] countServersOK()"); try {/*from ww w .j ava2 s. c o m*/ final Criteria criteria = session().createCriteria(Servidores.class); criteria.add(Restrictions.eq("status", "OK")); criteria.setProjection(Projections.rowCount()); final int count = ((Long) criteria.uniqueResult()).intValue(); return count; } catch (Exception e) { log.severe("[ " + userInfo.getLoggedUsername() + " ] Error: " + e); return 0; } }
From source file:br.com.hrstatus.dao.impl.ServersDAO.java
License:Open Source License
public int countServersNOK() { log.fine("Invoking countServersNOK()"); try {//from w w w . j a v a 2s .c o m final Criteria criteria = session().createCriteria(Servidores.class); criteria.add(Restrictions.or(Restrictions.eq("trClass", "Error"), Restrictions.eq("status", "NOK"))); criteria.setProjection(Projections.rowCount()); final int count = ((Long) criteria.uniqueResult()).intValue(); return count; } catch (Exception e) { log.severe("[ " + userInfo.getLoggedUsername() + " ] Error: " + e); return 0; } }
From source file:br.com.hrstatus.dao.impl.ServersDAO.java
License:Open Source License
public int countUnixOK() { log.fine("[ " + userInfo.getLoggedUsername() + " ] countUnixOK()"); try {//from w w w. ja v a 2 s. co m final Criteria criteria = session().createCriteria(Servidores.class); criteria.add(Restrictions.and(Restrictions.eq("SO", "UNIX"), Restrictions.eq("status", "OK"))); criteria.setProjection(Projections.rowCount()); final int count = ((Long) criteria.uniqueResult()).intValue(); log.fine("[ " + userInfo.getLoggedUsername() + " ] countUnixOK -> " + count + " found."); return count; } catch (Exception e) { log.severe("[ " + userInfo.getLoggedUsername() + " ] Error: " + e); return 0; } }
From source file:br.com.hrstatus.dao.impl.ServersDAO.java
License:Open Source License
public int countUnixNOK() { log.fine("[ " + userInfo.getLoggedUsername() + " ] countUnixNOK()"); try {/* w ww .j a v a 2 s. com*/ final Criteria criteria = session().createCriteria(Servidores.class); criteria.add(Restrictions.and(Restrictions.eq("SO", "UNIX"), (Restrictions.eq("trClass", "Error")))); criteria.setProjection(Projections.rowCount()); final int count = ((Long) criteria.uniqueResult()).intValue(); log.fine("[ " + userInfo.getLoggedUsername() + " ] countUnixNOK -> " + count + " found."); return count; } catch (Exception e) { log.severe("[ " + userInfo.getLoggedUsername() + " ] Error: " + e); return 0; } }
From source file:br.com.hrstatus.dao.impl.ServersDAO.java
License:Open Source License
public int countWindowsOK() { log.fine("[ " + userInfo.getLoggedUsername() + " ] countWindowsOK()"); try {//from w w w. j av a2s . c o m final Criteria criteria = session().createCriteria(Servidores.class); criteria.add(Restrictions.and(Restrictions.eq("SO", "WINDOWS"), Restrictions.eq("status", "OK"))); criteria.setProjection(Projections.rowCount()); final int count = ((Long) criteria.uniqueResult()).intValue(); log.fine("[ " + userInfo.getLoggedUsername() + " ] countWindowsOK -> " + count + " found."); return count; } catch (Exception e) { log.severe("[ " + userInfo.getLoggedUsername() + " ] Error: " + e); return 0; } }
From source file:br.com.hrstatus.dao.impl.ServersDAO.java
License:Open Source License
public int countWindowsNOK() { log.fine("[ " + userInfo.getLoggedUsername() + " ] countWindowsOK()"); try {/* w w w . j av a 2s . c om*/ final Criteria criteria = session().createCriteria(Servidores.class); criteria.add(Restrictions.and(Restrictions.eq("SO", "WINDOWS"), (Restrictions.eq("trClass", "Error")))); criteria.setProjection(Projections.rowCount()); final int count = ((Long) criteria.uniqueResult()).intValue(); log.fine("[ " + userInfo.getLoggedUsername() + " ] countWindowsNOK -> " + count + " found."); return count; } catch (Exception e) { log.severe("Error: " + e); return 0; } }