Example usage for org.hibernate.sql JoinType INNER_JOIN

List of usage examples for org.hibernate.sql JoinType INNER_JOIN

Introduction

In this page you can find the example usage for org.hibernate.sql JoinType INNER_JOIN.

Prototype

JoinType INNER_JOIN

To view the source code for org.hibernate.sql JoinType INNER_JOIN.

Click Source Link

Usage

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

License:Open Source License

public GenderType getSubjectGenderType(final String subjectUID, final Long studyId) {
    GenderType genderType = null;/*from w  ww .  j av a  2  s  .c  o  m*/
    Criteria criteria = getSession().createCriteria(LinkSubjectStudy.class, "lss");
    criteria.createAlias("study", "st", JoinType.INNER_JOIN);
    criteria.createAlias("person", "per", JoinType.INNER_JOIN);
    criteria.createAlias("per.genderType", "gen", JoinType.INNER_JOIN);

    criteria.setFetchMode("person", FetchMode.JOIN);

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

    List list = criteria.list();
    if (list.size() > 0) {
        LinkSubjectStudy subject = (LinkSubjectStudy) list.get(0);
        genderType = subject.getPerson().getGenderType();
    }
    return genderType;
}

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);/* w  ww  . j a v  a  2s .co  m*/

    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);//ww w .java  2s. co m
    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(/*w  w w . j av a2s .com*/
            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 w w.j a  va 2 s  . 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

public List<CustomField> getSelectedCalendarCustomFieldList(StudyCalendar studyCalendar) {
    List<CustomField> list = new ArrayList<CustomField>();
    Criteria criteria = getSession().createCriteria(CustomField.class);
    criteria.createAlias("linkCalendarCustomField", "lccf", JoinType.INNER_JOIN);
    criteria.createAlias("linkCalendarCustomField.studyCalendar", "sc", JoinType.INNER_JOIN);
    criteria.add(Restrictions.eq("sc.id", studyCalendar.getId()));
    list = criteria.list();/*from   ww  w  .  j a v a  2s .c om*/
    return list;
}

From source file:br.com.hslife.orcamento.repository.DocumentoRepository.java

License:Open Source License

@SuppressWarnings("unchecked")
public List<Documento> findByNomeAndUsuario(String nome, Usuario usuario) {
    Criteria criteria = getSession().createCriteria(Documento.class, "documento")
            .createAlias("documento.categoriaDocumento", "categoria", JoinType.INNER_JOIN);
    criteria.add(Restrictions.ilike("documento.nome", nome, MatchMode.ANYWHERE));
    criteria.add(Restrictions.eq("categoria.usuario.id", usuario.getId()));
    return criteria.addOrder(Order.asc("documento.nome")).list();
}

From source file:br.com.hslife.orcamento.repository.DocumentoRepository.java

License:Open Source License

@SuppressWarnings("unchecked")
public List<Documento> findByUsuario(Usuario usuario) {
    Criteria criteria = getSession().createCriteria(Documento.class, "documento")
            .createAlias("documento.categoriaDocumento", "categoria", JoinType.INNER_JOIN);
    criteria.add(Restrictions.eq("categoria.usuario.id", usuario.getId()));
    return criteria.addOrder(Order.asc("documento.nome")).list();
}

From source file:br.com.hslife.orcamento.repository.DocumentoRepository.java

License:Open Source License

@SuppressWarnings("unchecked")
public List<Documento> findByCategoriaDocumentoAndUsuario(CategoriaDocumento categoriaDocumento,
        Usuario usuario) {//from ww w.  ja  v a 2  s .  c  o  m
    Criteria criteria = getSession().createCriteria(Documento.class, "documento")
            .createAlias("documento.categoriaDocumento", "categoria", JoinType.INNER_JOIN);
    criteria.add(Restrictions.eq("documento.categoriaDocumento.id", categoriaDocumento.getId()));
    criteria.add(Restrictions.eq("categoria.usuario.id", usuario.getId()));
    return criteria.addOrder(Order.asc("documento.nome")).list();
}