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

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

License:Open Source License

public int countDB2() {

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

    final Criteria criteria = session().createCriteria(BancoDados.class);
    criteria.add(Restrictions.eq("vendor", "DB2"));
    criteria.setProjection(Projections.rowCount());
    final int count = ((Long) criteria.uniqueResult()).intValue();
    log.fine("[ " + userInfo.getLoggedUsername() + " ] countDB2() -> Found " + count + " DB2 Databases.");
    return count;
}

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

License:Open Source License

public int countAllDataBases() {
    final Criteria criteria = session().createCriteria(BancoDados.class);
    criteria.setProjection(Projections.rowCount());
    final int count = ((Long) criteria.uniqueResult()).intValue();
    log.fine("[ " + userInfo.getLoggedUsername() + " ] countAllDataBases() -> Found " + count + " Databases.");
    return count;
}

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

License:Open Source License

public int countDataBasesOK() {

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

    try {//from ww w . j a v  a  2  s  .  c  o  m
        final Criteria criteria = session().createCriteria(BancoDados.class);
        criteria.add(Restrictions.eq("status", "OK"));
        criteria.setProjection(Projections.rowCount());
        final int count = ((Long) criteria.uniqueResult()).intValue();
        log.fine("[ " + userInfo.getLoggedUsername() + " ] Data Bases OK: " + count);
        return count;

    } catch (Exception e) {
        System.out.println(e);
        log.severe("[ " + userInfo.getLoggedUsername() + " ] Error: " + e);
        return 0;
    }
}

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

License:Open Source License

public int countDataBasesNOK() {

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

    try {/*  w ww  .  j  av  a 2s. co  m*/
        final Criteria criteria = session().createCriteria(BancoDados.class);
        criteria.add(Restrictions.or(Restrictions.eq("trClass", "Error"), Restrictions.eq("status", "NOK")));
        criteria.setProjection(Projections.rowCount());
        final int count = ((Long) criteria.uniqueResult()).intValue();
        log.fine("[ " + userInfo.getLoggedUsername() + " ] Data Bases not NOK: " + count);
        return count;

    } catch (Exception e) {
        System.out.println(e);
        log.severe("[ " + userInfo.getLoggedUsername() + " ] Error: " + e);
        return 0;
    }
}

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

License:Open Source License

public int countMySQLOK() {

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

    try {/*from w  w  w.j  a  va 2s .co m*/
        final Criteria criteria = session().createCriteria(BancoDados.class);
        criteria.add(Restrictions.and(Restrictions.eq("vendor", "MYSQL"), Restrictions.eq("status", "OK")));
        criteria.setProjection(Projections.rowCount());
        final int count = ((Long) criteria.uniqueResult()).intValue();
        log.fine("[ " + userInfo.getLoggedUsername() + " ] countMySQLOK() -> " + count + " found.");
        return count;

    } catch (Exception e) {
        System.out.println(e);
        log.severe("[ " + userInfo.getLoggedUsername() + " ] Error: " + e);
        return 0;
    }
}

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

License:Open Source License

public int countMySQLNOK() {

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

    try {/*from ww w.  ja v a  2 s  .co  m*/
        final Criteria criteria = session().createCriteria(BancoDados.class);
        criteria.add(Restrictions.and(Restrictions.eq("vendor", "MYSQL"),
                Restrictions.or(Restrictions.eq("trClass", "Error"), Restrictions.eq("status", "NOK"))));
        criteria.setProjection(Projections.rowCount());
        final int count = ((Long) criteria.uniqueResult()).intValue();
        log.fine("[ " + userInfo.getLoggedUsername() + " ] countMySQLNOK() -> " + count + " found.");
        return count;

    } catch (Exception e) {
        System.out.println(e);
        log.severe("[ " + userInfo.getLoggedUsername() + " ] Error: " + e);
        return 0;
    }
}

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

License:Open Source License

public int countOracleOK() {

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

    try {// w w w . j a  v  a2 s.c  o  m
        final Criteria criteria = session().createCriteria(BancoDados.class);
        criteria.add(Restrictions.and(Restrictions.eq("vendor", "ORACLE"), Restrictions.eq("status", "OK")));
        criteria.setProjection(Projections.rowCount());
        final int count = ((Long) criteria.uniqueResult()).intValue();
        log.fine("[ " + userInfo.getLoggedUsername() + " ] countOracleOK() -> " + count + " found.");
        return count;

    } catch (Exception e) {
        System.out.println(e);
        log.severe("[ " + userInfo.getLoggedUsername() + " ] Error: " + e);
        return 0;
    }
}

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

License:Open Source License

public int countOracleNOK() {

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

    try {//ww w. j  a  va  2s .c o m
        final Criteria criteria = session().createCriteria(BancoDados.class);
        criteria.add(Restrictions.and(Restrictions.eq("vendor", "ORACLE"),
                Restrictions.or(Restrictions.eq("trClass", "Error"), Restrictions.eq("status", "NOK"))));
        criteria.setProjection(Projections.rowCount());
        final int count = ((Long) criteria.uniqueResult()).intValue();
        log.fine("[ " + userInfo.getLoggedUsername() + " ] countOracleNOK() -> " + count + " found.");
        return count;

    } catch (Exception e) {
        System.out.println(e);
        log.severe("[ " + userInfo.getLoggedUsername() + " ] Error: " + e);
        return 0;
    }
}