Example usage for org.hibernate Criteria setProjection

List of usage examples for org.hibernate Criteria setProjection

Introduction

In this page you can find the example usage for org.hibernate Criteria setProjection.

Prototype

public Criteria setProjection(Projection projection);

Source Link

Document

Used to specify that the query results will be a projection (scalar in nature).

Usage

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  w ww  .  j a  va 2s  .  co 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 {/*from   w  ww  . j ava2 s  .  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.c  o  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 {//  w  ww .j  a v a 2s  .  c  o  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 {/*from  w  w w .j av  a2s  .  c  om*/
        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 {/*w  ww  .  j  av a  2  s .  co  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;
    }
}

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

License:Open Source License

public int countPostgreOK() {

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

    try {//w w  w. j ava  2s  .c  o m
        final Criteria criteria = session().createCriteria(BancoDados.class);
        criteria.add(
                Restrictions.and(Restrictions.eq("vendor", "POSTGRESQL"), Restrictions.eq("status", "OK")));
        criteria.setProjection(Projections.rowCount());
        final int count = ((Long) criteria.uniqueResult()).intValue();
        log.fine("[ " + userInfo.getLoggedUsername() + " ] countPostgreOK -> " + 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 countPostgreNOK() {

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

    try {/*from   www  .  j a  va 2 s.c  o  m*/
        final Criteria criteria = session().createCriteria(BancoDados.class);
        criteria.add(Restrictions.and(Restrictions.eq("vendor", "POSTGRESQL"),
                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() + " ] countPostgreNOK() -> " + count + " found.");
        return count;

    } catch (Exception e) {
        log.severe("Error: " + e);
        return 0;
    }
}