Example usage for org.hibernate.criterion Projections rowCount

List of usage examples for org.hibernate.criterion Projections rowCount

Introduction

In this page you can find the example usage for org.hibernate.criterion Projections rowCount.

Prototype

public static Projection rowCount() 

Source Link

Document

The query row count, ie.

Usage

From source file:br.com.hrstatus.dao.impl.ServersDAO.java

License:Open Source License

public int countServersNOK() {

    log.fine("Invoking countServersNOK()");

    try {/*from ww w  . jav a2  s .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 {/* w w  w.  j a va 2  s .  com*/

        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 {/*from   ww  w  . j a  va2 s .  co  m*/

        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  a v a  2 s.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 {//from  w  w w  . j  a v  a2s  .  c o m

        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;
    }
}

From source file:br.com.hrstatus.dao.impl.ServersDAO.java

License:Open Source License

public int countOtherOK() {

    log.fine("[ " + userInfo.getLoggedUsername() + " ] countOtherOK()");

    try {/*from   w  w  w .j  a  v a  2 s  .com*/

        final Criteria criteria = session().createCriteria(Servidores.class);
        criteria.add(Restrictions.ne("SO", "Windows"));
        criteria.add(Restrictions.ne("SO", "Unix"));
        criteria.add(Restrictions.eq("status", "OK"));
        criteria.setProjection(Projections.rowCount());
        final int count = ((Long) criteria.uniqueResult()).intValue();
        log.fine("[ " + userInfo.getLoggedUsername() + " ] countOtherOK -> " + 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 countServerWithLog() {

    log.fine("[ " + userInfo.getLoggedUsername() + " ] countServerWithLog()");

    try {/*  w  ww. j a  v a  2s  . c o m*/
        final Criteria criteria = session().createCriteria(Servidores.class);
        criteria.add(Restrictions.not(Restrictions.eq("logDir", "")));
        criteria.setProjection(Projections.rowCount());
        final int count = ((Long) criteria.uniqueResult()).intValue();
        log.fine("[ " + userInfo.getLoggedUsername() + " ] countServerWithLog -> found: " + count);
        return count;
    } catch (Exception e) {
        log.severe("[ " + userInfo.getLoggedUsername() + " ] Error: " + e);
        return 0;
    }
}

From source file:br.com.hrstatus.dao.impl.UsersDAO.java

License:Open Source License

public int searchUser(String username) {

    log.fine("[ " + userInfo.getLoggedUsername() + " ] searchUser(String username)[" + username + "]");
    final Criteria criteria = session().createCriteria(Users.class);
    criteria.add(Restrictions.eq("username", username));
    criteria.setProjection(Projections.rowCount());
    final int count = ((Long) criteria.uniqueResult()).intValue();
    return count;
}

From source file:br.com.hrstatus.dao.impl.UsersDAO.java

License:Open Source License

public int searchUserNotLogged(String username) {

    log.fine("[ System ] searchUser(String username)[" + username + "]");
    final Criteria criteria = session().createCriteria(Users.class);
    criteria.add(Restrictions.eq("username", username));
    criteria.setProjection(Projections.rowCount());
    final int count = ((Long) criteria.uniqueResult()).intValue();
    return count;
}

From source file:br.com.hrstatus.dao.impl.UsersDAO.java

License:Open Source License

public int searchUserChangePass(String username) {

    log.fine(/*from   ww w  . j a v  a 2s. c o m*/
            "[ " + userInfo.getLoggedUsername() + " ] searchUserChangePass(String username)[" + username + "]");
    final Criteria criteria = session().createCriteria(PassExpire.class);
    criteria.add(Restrictions.eq("username", username));
    criteria.setProjection(Projections.rowCount());
    final int count = ((Long) criteria.uniqueResult()).intValue();
    return count;
}