Example usage for org.hibernate Criteria list

List of usage examples for org.hibernate Criteria list

Introduction

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

Prototype

public List list() throws HibernateException;

Source Link

Document

Get the results.

Usage

From source file:au.org.theark.study.model.dao.StudyDao.java

License:Open Source License

public List<TwinType> getTwinTypes() {
    Example example = Example.create(new TwinType());
    Criteria criteria = getSession().createCriteria(TwinType.class).add(example);
    return criteria.list();
}

From source file:au.org.theark.study.model.dao.StudyDao.java

License:Open Source License

public Integer getSubjectParentCount(final LinkSubjectStudy subject) {
    Criteria criteria = getSession().createCriteria(LinkSubjectPedigree.class);
    criteria.add(Restrictions.eq("subject", subject));
    criteria.setProjection(Projections.rowCount());
    return ((Integer) criteria.list().get(0)).intValue();
}

From source file:au.org.theark.study.model.dao.StudyDao.java

License:Open Source License

public List<LinkSubjectPedigree> getSubjectParentRelationshipList(final LinkSubjectStudy subject) {
    Criteria criteria = getSession().createCriteria(LinkSubjectPedigree.class);
    criteria.add(Restrictions.eq("subject", subject));
    return criteria.list();
}

From source file:au.org.theark.study.model.dao.StudyDao.java

License:Open Source License

public List<LinkSubjectPedigree> getParentNonSubjectRelationshipList(final LinkSubjectStudy subject,
        final LinkSubjectStudy parentSubject) {
    Criteria criteria = getSession().createCriteria(LinkSubjectPedigree.class);
    criteria.add(Restrictions.eq("relative", parentSubject));
    criteria.add(Restrictions.ne("subject", subject));
    return criteria.list();
}

From source file:au.org.theark.study.model.dao.StudyDao.java

License:Open Source License

public List<LinkSubjectTwin> getTwins(final Set<String> subjectUids, final Long studyId) {
    List<LinkSubjectTwin> twins = new ArrayList<LinkSubjectTwin>();
    Criteria criteria = getSession().createCriteria(LinkSubjectTwin.class, "lst");
    criteria.createAlias("firstSubject", "lssa", JoinType.INNER_JOIN);
    criteria.createAlias("lssa.study", "sta", JoinType.INNER_JOIN);
    criteria.createAlias("secondSubject", "lssb", JoinType.INNER_JOIN);
    criteria.createAlias("lssb.study", "stb", JoinType.INNER_JOIN);

    criteria.setFetchMode("firstSubject", FetchMode.JOIN);
    criteria.setFetchMode("secondSubject", FetchMode.JOIN);
    criteria.setFetchMode("twinType", FetchMode.JOIN);

    criteria.add(Restrictions.eq("sta.id", studyId));
    criteria.add(Restrictions.eq("stb.id", studyId));
    Disjunction or = Restrictions.disjunction();
    or.add(Restrictions.in("lssa.subjectUID", subjectUids));
    or.add(Restrictions.in("lssb.subjectUID", subjectUids));
    criteria.add(or);//from w  w w.  jav  a2s  .  com

    twins = criteria.list();

    return twins;

}

From source file:au.org.theark.study.model.dao.StudyDao.java

License:Open Source License

public long getRelationshipCount(final String subjectUID, final Long studyId) {
    long count = 0;
    Criteria criteria = getSession().createCriteria(LinkSubjectPedigree.class, "lsp");
    criteria.createAlias("subject", "sub", JoinType.INNER_JOIN);
    criteria.createAlias("relative", "rel", JoinType.INNER_JOIN);
    criteria.createAlias("sub.study", "substudy", JoinType.INNER_JOIN);
    criteria.createAlias("rel.study", "relstudy", JoinType.INNER_JOIN);
    criteria.add(Restrictions.eq("substudy.id", studyId));
    criteria.add(Restrictions.eq("relstudy.id", studyId));
    Disjunction or = Restrictions.disjunction();
    or.add(Restrictions.eq("sub.subjectUID", subjectUID));
    or.add(Restrictions.eq("rel.subjectUID", subjectUID));
    criteria.add(or);/*from w w w.  ja  v  a2  s.  c om*/
    ProjectionList projList = Projections.projectionList();
    projList.add(Projections.count("lsp.id"));
    criteria.setProjection(projList);
    List list = criteria.list();
    if (list.size() > 0) {
        count = Integer.parseInt(list.get(0).toString());
    }
    return count;
}

From source file:au.org.theark.study.model.dao.StudyDao.java

License:Open Source License

public List<CustomField> getBinaryCustomFieldsForPedigreeRelativesList(Long studyId) {
    List<CustomField> pedigreeCustomFields = null;
    Criteria criteria = getSession().createCriteria(CustomField.class, "cf");
    criteria.createAlias("study", "st", JoinType.INNER_JOIN);
    criteria.createAlias("arkFunction", "af", JoinType.INNER_JOIN);
    criteria.createAlias("customFieldType", "cft", JoinType.LEFT_OUTER_JOIN);
    criteria.createAlias("fieldType", "ft", JoinType.INNER_JOIN);
    criteria.add(Restrictions.eq("st.id", studyId));
    criteria.add(/*from  w  ww . j av  a2  s. c om*/
            Restrictions.eq("af.name", au.org.theark.core.Constants.FUNCTION_KEY_VALUE_SUBJECT_CUSTOM_FIELD));
    criteria.add(Restrictions.eq("cf.encodedValues", "0=Yes;1=No;").ignoreCase());
    criteria.add(Restrictions.or(Restrictions.isNull("cft.id"),
            Restrictions.eq("cft.name", au.org.theark.core.Constants.SUBJECT)));
    pedigreeCustomFields = criteria.list();

    return pedigreeCustomFields;
}

From source file:au.org.theark.study.model.dao.StudyDao.java

License:Open Source License

@Override
public List<CustomField> getFamilyUIdCustomFieldsForPedigreeRelativesList(Long studyId) {
    List<CustomField> pedigreeCustomFields = null;
    Criteria criteria = getSession().createCriteria(CustomField.class, "cf");
    criteria.createAlias("study", "st", JoinType.INNER_JOIN);
    criteria.createAlias("arkFunction", "af", JoinType.INNER_JOIN);
    criteria.createAlias("fieldType", "ft", JoinType.INNER_JOIN);
    criteria.createAlias("customFieldType", "cft", JoinType.LEFT_OUTER_JOIN);
    criteria.add(Restrictions.eq("st.id", studyId));
    criteria.add(//w ww .  ja va2s  .  c  om
            Restrictions.eq("af.name", au.org.theark.core.Constants.FUNCTION_KEY_VALUE_SUBJECT_CUSTOM_FIELD));
    criteria.add(Restrictions.isNull("cf.encodedValues"));
    criteria.add(Restrictions.eq("ft.name", au.org.theark.core.Constants.FIELD_TYPE_CHARACTER));
    criteria.add(Restrictions.or(Restrictions.isNull("cft.id"),
            Restrictions.eq("cft.name", au.org.theark.core.Constants.SUBJECT)));

    pedigreeCustomFields = criteria.list();

    return pedigreeCustomFields;
}

From source file:au.org.theark.study.model.dao.StudyDao.java

License:Open Source License

public StudyPedigreeConfiguration getStudyPedigreeConfiguration(Long studyId) {

    StudyPedigreeConfiguration pedigreeConfig = null;

    Criteria criteria = getSession().createCriteria(StudyPedigreeConfiguration.class, "spc");
    criteria.createAlias("study", "st", JoinType.INNER_JOIN);
    criteria.setFetchMode("customField", FetchMode.JOIN);

    criteria.add(Restrictions.eq("st.id", studyId));

    List<StudyPedigreeConfiguration> list = criteria.list();
    pedigreeConfig = list.size() == 1 ? list.get(0) : new StudyPedigreeConfiguration();

    return pedigreeConfig;

}

From source file:au.org.theark.study.model.dao.StudyDao.java

License:Open Source License

/**
 * Pageable person phone list.//ww w  .j  ava2 s .c om
 */
public List<Phone> pageablePersonPhoneLst(Long personId, Phone phoneCriteria, int first, int count) {
    Criteria criteria = buildGeneralPhoneCriteria(personId, phoneCriteria);
    criteria.setFirstResult(first);
    criteria.setMaxResults(count);
    List<Phone> personPhoneList = criteria.list();
    //log.info("Number of phones fetched " + personPhoneList.size() + "  Person Id" + personId.intValue());
    if (personPhoneList.isEmpty()) {
        // throw new EntityNotFoundException("The entity with id" + personId.toString() + " cannot be found.");
        log.info(" personId " + personId + " had no phones.  No drama");
    }
    return personPhoneList;
}