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:au.org.theark.core.dao.StudyDao.java

License:Open Source License

public BiospecimenUidTemplate getBiospecimentUidTemplate(Study study) {
    Criteria criteria = getSession().createCriteria(BiospecimenUidTemplate.class);
    criteria.add(Restrictions.eq("study", study));
    return (BiospecimenUidTemplate) criteria.uniqueResult();
}

From source file:au.org.theark.core.dao.StudyDao.java

License:Open Source License

public BioCollectionUidTemplate getBioCollectionUidTemplate(Study study) {
    Criteria criteria = getSession().createCriteria(BioCollectionUidTemplate.class);
    criteria.add(Restrictions.eq("study", study));
    return (BioCollectionUidTemplate) criteria.uniqueResult();
}

From source file:au.org.theark.core.dao.StudyDao.java

License:Open Source License

public UploadStatus getUploadStatusFor(String statusFromConstant) {
    Criteria criteria = getSession().createCriteria(UploadStatus.class);
    criteria.add(Restrictions.eq("name", statusFromConstant));
    return (UploadStatus) criteria.uniqueResult();
}

From source file:au.org.theark.core.dao.StudyDao.java

License:Open Source License

public ArkModule getArkModuleForSubject() {
    Criteria criteria = getSession().createCriteria(ArkModule.class);
    criteria.add(Restrictions.eq("name", "Subject"));
    return (ArkModule) criteria.uniqueResult();
}

From source file:au.org.theark.core.dao.StudyDao.java

License:Open Source License

public ArkModule getArkModuleForLims() {
    Criteria criteria = getSession().createCriteria(ArkModule.class);
    criteria.add(Restrictions.eq("name", "LIMS"));
    return (ArkModule) criteria.uniqueResult();
}

From source file:au.org.theark.core.dao.StudyDao.java

License:Open Source License

public YesNo getYes() {
    Criteria criteria = getSession().createCriteria(YesNo.class);
    criteria.add(Restrictions.eq("name", "Yes"));
    return (YesNo) criteria.uniqueResult();
}

From source file:au.org.theark.core.dao.StudyDao.java

License:Open Source License

public YesNo getNo() {
    Criteria criteria = getSession().createCriteria(YesNo.class);
    criteria.add(Restrictions.eq("name", "No"));
    return (YesNo) criteria.uniqueResult();
}

From source file:au.org.theark.core.dao.StudyDao.java

License:Open Source License

public ConsentStatus getConsentStatusByName(String name) {
    Criteria criteria = getSession().createCriteria(ConsentStatus.class);
    criteria.add(Restrictions.eq("name", name));
    return (ConsentStatus) criteria.uniqueResult();
}

From source file:au.org.theark.core.dao.StudyDao.java

License:Open Source License

@Override
public UserConfig getUserConfig(ArkUser arkUser, ConfigField configField) {
    Criteria criteria = getSession().createCriteria(UserConfig.class);
    if (arkUser != null && arkUser.getId() != null) {
        criteria.add(Restrictions.eq("arkUser", arkUser));
    }// ww w. j a va  2 s. c om
    if (configField != null && configField.getId() != null) {
        criteria.add(Restrictions.eq("configField", configField));
    }
    UserConfig userConfig = null;
    try {
        userConfig = (UserConfig) criteria.uniqueResult();
    } catch (HibernateException e) {
        log.error(e.getMessage());
        e.printStackTrace();
        userConfig = new UserConfig();
        userConfig.setArkUser(arkUser);
        userConfig.setConfigField(configField);
        //         userConfig.setValue(configField.getDefaultValue());
    }
    return userConfig;
}

From source file:au.org.theark.core.dao.StudyDao.java

License:Open Source License

public ConfigField getConfigFieldByName(String configField) {
    Criteria criteria = getSession().createCriteria(ConfigField.class);
    criteria.add(Restrictions.eq("name", configField));
    return (ConfigField) criteria.uniqueResult();
}