Example usage for org.hibernate Criteria uniqueResult

List of usage examples for org.hibernate Criteria uniqueResult

Introduction

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

Prototype

public Object uniqueResult() throws HibernateException;

Source Link

Document

Convenience method to return a single instance that matches the query, or null if the query returns no results.

Usage

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

License:Open Source License

public String getDestsNotLogged() {

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

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

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

License:Open Source License

public String getJndiMail() {

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

    final Criteria subject = session().createCriteria(Configurations.class);
    final ProjectionList proList = Projections.projectionList();
    proList.add(Projections.property("jndiMail"));
    subject.setProjection(proList);/*from   w  w  w.j  av  a2s. com*/
    return (String) subject.uniqueResult();
}

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

License:Open Source License

public String getJndiMailNotLogged() {

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

    final Criteria subject = session().createCriteria(Configurations.class);
    final ProjectionList proList = Projections.projectionList();
    proList.add(Projections.property("jndiMail"));
    subject.setProjection(proList);// w  w  w.j a va 2 s.  co  m
    return (String) subject.uniqueResult();
}

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

License:Open Source License

public int getDiffirenceSecs() {

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

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

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);/*  ww  w. ja  v a 2s .  com*/
    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 ww. j  a v a  2  s .c om
    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  w  ww  . ja va 2  s .c  o  m*/
    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 {// ww  w.  j  a  v a  2 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  ww.ja  v  a2  s .c  om
    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.ja v  a  2  s .c om

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

}