Example usage for org.hibernate.criterion Projections property

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

Introduction

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

Prototype

public static PropertyProjection property(String propertyName) 

Source Link

Document

A property value projection

Usage

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

License:Open Source License

public int getDiffirenceSecsScheduler(String schedulerName) {

    log.fine("[ " + schedulerName + " ] getDiffirenceSecsScheduler()");

    final Criteria difference = session().createCriteria(Configurations.class);
    final ProjectionList proList = Projections.projectionList();
    proList.add(Projections.property("difference"));
    difference.setProjection(proList);//  w w w  . ja v  a  2s. c  om
    final int value = (Integer) difference.uniqueResult();
    return value;
}

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

License:Open Source License

public String getNtpServerAddress() {

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

    final Criteria ntpServer = session().createCriteria(Configurations.class);
    final ProjectionList proList = Projections.projectionList();
    proList.add(Projections.property("ntpServer"));
    ntpServer.setProjection(proList);// w  w w . jav a 2  s  .com
    return (String) ntpServer.uniqueResult();
}

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

License:Open Source License

public String getNtpServerAddressNotLogged() {

    log.fine("[ System ] getNtpServerAddress()");

    final Criteria ntpServer = session().createCriteria(Configurations.class);
    final ProjectionList proList = Projections.projectionList();
    proList.add(Projections.property("ntpServer"));
    ntpServer.setProjection(proList);//from   ww w .j  ava 2 s .  c om
    return (String) ntpServer.uniqueResult();
}

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

License:Open Source License

public boolean freshInstall() {

    log.fine("[ System ] invoking freshInstall()");

    final Criteria freshInstall = session().createCriteria(InstallationProcess.class);
    final ProjectionList proList = Projections.projectionList();
    proList.add(Projections.property("freshInstall"));
    freshInstall.setProjection(proList);

    boolean result = false;

    try {/*from w ww  .  jav a2  s  . c om*/
        final String temp = freshInstall.uniqueResult().toString();

        if (new Boolean(temp)) {
            result = true;
        } else if (!new Boolean(temp)) {
            result = false;
        }
    } catch (java.lang.NullPointerException NPE) {
        result = true;
    }
    return result;
}

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

License:Open Source License

public String getInstallationDate() {

    log.fine("[ System ] invoking getInstallationDate()");
    final Criteria installDate = session().createCriteria(InstallationProcess.class);
    final ProjectionList proList = Projections.projectionList();
    proList.add(Projections.property("installDate"));
    installDate.setProjection(proList);/*from  w w  w .j  a va 2  s.  c o  m*/
    return installDate.uniqueResult().toString();
}

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

License:Open Source License

public int insert_server(Servidores server) {

    log.info("[ " + userInfo.getLoggedUsername() + " ] insert_server(Server server)");
    log.fine("Server: " + server.getHostname());
    log.fine("IP: " + server.getIp());
    log.fine("User: " + server.getUser());
    log.fine("Pass: gotcha!");
    log.fine("Port: " + server.getPort());
    log.fine("OS: " + server.getSO());
    log.fine("Status: " + server.getStatus());
    log.fine("Logs directory: " + server.getLogDir());
    log.fine("Su command: " + server.getSuCommand());
    log.fine("Verify? -> " + server.getVerify());

    try {//  www  .j  a  v a  2 s. c  o  m

        final Criteria hostname = session().createCriteria(Servidores.class)
                .add(Restrictions.eq("hostname", new String(server.getHostname())))
                .setProjection(Projections.property("hostname"));

        if (hostname.uniqueResult() == null) {
            log.info("[ " + userInfo.getLoggedUsername() + " ] insert_server -> Server " + server.getHostname()
                    + " not found.");
            log.info("[ " + userInfo.getLoggedUsername() + " ] insert_server -> Saving data");
            session().save(server);
            return 0;
        } else {
            log.info("[ " + userInfo.getLoggedUsername() + " ] insert_server -> Server " + server.getHostname()
                    + " already exists, server not registered.");
            return 1;
        }

    } catch (Exception e) {
        log.severe("[ " + userInfo.getLoggedUsername() + " ] insert_server -> Error: " + e);
        return 1;
    }

}

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

License:Open Source License

@SuppressWarnings("unchecked")
public List<Servidores> getHostnames() {

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

    try {//from  w ww.  j a  v a  2 s  .co m

        final Criteria criteriaHostname = session().createCriteria(Servidores.class);
        final ProjectionList proList = Projections.projectionList();
        proList.add(Projections.property("id"));
        proList.add(Projections.property("hostname"));
        criteriaHostname.setProjection(proList);
        return criteriaHostname.list();

    } catch (Exception e) {
        log.severe("Error: " + e);
        return new ArrayList<Servidores>();
    }
}

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

License:Open Source License

public String getPass(String username) {

    log.fine("[ " + userInfo.getLoggedUsername() + " ] getPass(String user)[" + username + "]");

    final Criteria criteria = session().createCriteria(Users.class);
    criteria.add(Restrictions.eq("username", username));
    final ProjectionList proList = Projections.projectionList();
    proList.add(Projections.property("password"));
    criteria.setProjection(proList);//ww w  .  j  a va 2 s.  c o  m
    return criteria.uniqueResult().toString();
}

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

License:Open Source License

public String getMail(String username) {

    log.fine("[ " + userInfo.getLoggedUsername() + " ] getMail(String username)[" + username + "]");
    final Criteria criteria = session().createCriteria(Users.class);
    criteria.add(Restrictions.eq("username", username));
    final ProjectionList proList = Projections.projectionList();
    proList.add(Projections.property("mail"));
    criteria.setProjection(proList);/*from w w  w .jav a 2  s.  com*/
    return criteria.uniqueResult().toString();
}

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

License:Open Source License

public String getMailNotLogged(String username) {

    log.fine("[ System ] getMail(String username)[" + username + "]");
    final Criteria criteria = session().createCriteria(Users.class);
    criteria.add(Restrictions.eq("username", username));
    final ProjectionList proList = Projections.projectionList();
    proList.add(Projections.property("mail"));
    criteria.setProjection(proList);//from  w ww .  ja v a2 s . c  o m
    return criteria.uniqueResult().toString();
}