Example usage for org.hibernate.transform Transformers aliasToBean

List of usage examples for org.hibernate.transform Transformers aliasToBean

Introduction

In this page you can find the example usage for org.hibernate.transform Transformers aliasToBean.

Prototype

public static ResultTransformer aliasToBean(Class target) 

Source Link

Document

Creates a resulttransformer that will inject aliased values into instances of Class via property methods or fields.

Usage

From source file:au.org.theark.admin.model.dao.AdminDao.java

License:Open Source License

protected Criteria buildArkRoleModuleFunctionVoCriteria(
        ArkRoleModuleFunctionVO arkRoleModuleFunctionVoCriteria) {
    Criteria criteria = getSession().createCriteria(ArkRolePolicyTemplate.class, "arpt");

    if (arkRoleModuleFunctionVoCriteria.getArkRole() != null) {
        criteria.add(Restrictions.eq("arpt.arkRole", arkRoleModuleFunctionVoCriteria.getArkRole()));
    }//from   ww  w .j a v  a  2s.  c  om

    if (arkRoleModuleFunctionVoCriteria.getArkModule() != null) {
        criteria.add(Restrictions.eq("arpt.arkModule", arkRoleModuleFunctionVoCriteria.getArkModule()));
    }

    if (arkRoleModuleFunctionVoCriteria.getArkFunction() != null) {
        criteria.add(Restrictions.eq("arpt.arkFunction", arkRoleModuleFunctionVoCriteria.getArkFunction()));
    }

    ProjectionList projectionList = Projections.projectionList();
    projectionList.add(Projections.groupProperty("arpt.arkRole"), "arkRole");
    projectionList.add(Projections.groupProperty("arpt.arkModule"), "arkModule");
    projectionList.add(Projections.groupProperty("arpt.arkFunction"), "arkFunction");

    criteria.setProjection(projectionList);

    ResultTransformer resultTransformer = Transformers.aliasToBean(ArkRoleModuleFunctionVO.class);
    criteria.setResultTransformer(resultTransformer);

    return criteria;
}

From source file:au.org.theark.admin.model.dao.AdminDao.java

License:Open Source License

public List<ArkRoleModuleFunctionVO> getArkRoleModuleFunctionVoList(ArkRole arkRole) {
    Criteria criteria = getSession().createCriteria(ArkRolePolicyTemplate.class, "arpt");
    criteria.add(Restrictions.eq("arpt.arkRole", arkRole));

    ProjectionList projectionList = Projections.projectionList();
    projectionList.add(Projections.groupProperty("arpt.arkRole"), "arkRole");
    projectionList.add(Projections.groupProperty("arpt.arkModule"), "arkModule");
    projectionList.add(Projections.groupProperty("arpt.arkFunction"), "arkFunction");

    criteria.setProjection(projectionList);

    ResultTransformer resultTransformer = Transformers.aliasToBean(ArkRoleModuleFunctionVO.class);
    criteria.setResultTransformer(resultTransformer);

    return criteria.list();
}

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

License:Open Source License

@SuppressWarnings("unchecked")
public List<ArkUser> getArkUserListByStudy(ArkUser arkUser, Study study) {
    Criteria criteria = getSession().createCriteria(ArkUserRole.class);
    // Restrict by user if NOT Super Administrator
    try {// w  w  w.  j av  a 2 s  .  c om
        if (!isUserAdminHelper(arkUser.getLdapUserName(), RoleConstants.ARK_ROLE_SUPER_ADMINISTATOR)) {
            criteria.add(Restrictions.eq("study", study));
        }
    } catch (EntityNotFoundException e) {
        log.info("User Name doen not exsists");
    }
    ProjectionList projectionList = Projections.projectionList();
    projectionList.add(Projections.groupProperty("arkUser"), "arkUser");
    criteria.setProjection(projectionList);
    criteria.setResultTransformer(Transformers.aliasToBean(ArkUserRole.class));
    List<ArkUserRole> arkUserRoles = (List<ArkUserRole>) criteria.list();
    List<ArkUser> arkUserLst = new ArrayList<ArkUser>();
    for (ArkUserRole arkRolePol : arkUserRoles) {
        arkUserLst.add(arkRolePol.getArkUser());
    }
    //Added on 2015-12-10 filter study wise users.
    //changed on 2016-04-28.
    return arkUserLst;
}

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

License:Open Source License

/**
 * List of Permission for function. /*from w  ww . j  av  a 2  s. c  o  m*/
 *
 * Just I need the list of permission list for a particular function I manage to use the hibernate projectionList property.
 * Group by Permission.
 * But still used setResultTransformer to transform the list which include the permission list.
 * @return
 */
public List<ArkPermission> getArkPremissionListForRoleAndModule(ArkRolePolicyTemplate arkRolePolicyTemplate) {
    Criteria criteria = getSession().createCriteria(ArkRolePolicyTemplate.class);
    criteria.add(Restrictions.eq("arkRole", arkRolePolicyTemplate.getArkRole()));
    criteria.add(Restrictions.eq("arkModule", arkRolePolicyTemplate.getArkModule()));
    criteria.add(Restrictions.eq("arkFunction", arkRolePolicyTemplate.getArkFunction()));
    ProjectionList projectionList = Projections.projectionList();
    projectionList.add(Projections.groupProperty("arkPermission"), "arkPermission");
    criteria.setProjection(projectionList);
    criteria.setResultTransformer(Transformers.aliasToBean(ArkRolePolicyTemplate.class));
    List<ArkRolePolicyTemplate> arkRolePolicyTemplatesLst = (List<ArkRolePolicyTemplate>) criteria.list();
    List<ArkPermission> arkPermissionLst = new ArrayList<ArkPermission>();
    for (ArkRolePolicyTemplate arkRolePol : arkRolePolicyTemplatesLst) {
        arkPermissionLst.add(arkRolePol.getArkPermission());
    }
    return arkPermissionLst;
}

From source file:au.org.theark.phenotypic.model.dao.PhenotypicDao.java

License:Open Source License

public List<PhenoDataSetGroup> getPhenoDataSetGroupsByLinkSubjectStudy(LinkSubjectStudy linkSubjectStudy) {
    Criteria criteria = getSession().createCriteria(PhenoDataSetCollection.class);
    criteria.add(Restrictions.eq("linkSubjectStudy", linkSubjectStudy));
    ProjectionList projectionList = Projections.projectionList();
    projectionList.add(Projections.groupProperty("questionnaire"), "questionnaire");
    criteria.setProjection(projectionList);
    criteria.setResultTransformer(Transformers.aliasToBean(PhenoDataSetCollection.class));
    List<PhenoDataSetCollection> phenoDataSetCollections = (List<PhenoDataSetCollection>) criteria.list();
    List<PhenoDataSetGroup> phenoDataSetGroups = new ArrayList<PhenoDataSetGroup>();
    for (PhenoDataSetCollection phenoDataSetCollection : phenoDataSetCollections) {
        phenoDataSetGroups.add(phenoDataSetCollection.getQuestionnaire());
    }//from  w w w  .ja va2 s.com
    return phenoDataSetGroups;
}

From source file:au.org.theark.phenotypic.model.dao.PhenotypicDao.java

License:Open Source License

@Override
public List<PhenoDataSetFieldDisplay> getPhenoDataSetFieldDisplayForPhenoDataSetFieldGroupOrderByPhenoDataSetCategory(
        PhenoDataSetGroup phenoDataSetGroup) {
    Criteria criteria = getSession().createCriteria(PhenoDataSetFieldDisplay.class);
    criteria.add(Restrictions.eq("phenoDataSetGroup", phenoDataSetGroup));
    ProjectionList projectionList = Projections.projectionList();
    projectionList.add(Projections.groupProperty("phenoDataSetGroup"), "phenoDataSetGroup");
    projectionList.add(Projections.groupProperty("phenoDataSetCategory"), "phenoDataSetCategory");
    projectionList.add(Projections.groupProperty("parentPhenoDataSetCategory"), "parentPhenoDataSetCategory");
    projectionList.add(Projections.groupProperty("phenoDataSetCategoryOrderNumber"),
            "phenoDataSetCategoryOrderNumber");
    criteria.setProjection(projectionList);
    criteria.addOrder(Order.asc("phenoDataSetCategoryOrderNumber"));
    criteria.setResultTransformer(Transformers.aliasToBean(PhenoDataSetFieldDisplay.class));
    return (List<PhenoDataSetFieldDisplay>) criteria.list();
}

From source file:au.org.theark.phenotypic.model.dao.PhenotypicDao.java

License:Open Source License

@Override
public List<Boolean> getPublishedSatusLst(Study study, ArkFunction arkFunction) {
    Criteria criteria = getSession().createCriteria(PhenoDataSetGroup.class);
    criteria.add(Restrictions.eq("study", study));
    criteria.add(Restrictions.eq("arkFunction", arkFunction));
    ProjectionList projectionList = Projections.projectionList();
    projectionList.add(Projections.groupProperty("published"), "published");
    criteria.setProjection(projectionList);
    criteria.setResultTransformer(Transformers.aliasToBean(PhenoDataSetGroup.class));
    List<PhenoDataSetGroup> phenoDataSetGroups = (List<PhenoDataSetGroup>) criteria.list();
    List<Boolean> pubishStatusLst = new ArrayList<Boolean>();
    for (PhenoDataSetGroup phenoDataSetGroup : phenoDataSetGroups) {
        pubishStatusLst.add(phenoDataSetGroup.getPublished());
    }/*  ww  w . jav  a 2  s.  co  m*/
    return pubishStatusLst;
}

From source file:au.org.theark.report.model.dao.ReportDao.java

License:Open Source License

public List<ConsentDetailsDataRow> getStudyLevelConsentDetailsDataRowList(ConsentDetailsReportVO cdrVO) {
    List<ConsentDetailsDataRow> resultList = new ArrayList<ConsentDetailsDataRow>(0);

    Criteria criteria = getSession().createCriteria(LinkSubjectStudy.class, "lss");
    // Add study in context to criteria first (linkSubjectStudy on the VO should never be null)
    criteria.add(/*from   w ww  .  j  a v a  2  s.  c  o  m*/
            Restrictions.eq("lss." + Constants.LINKSUBJECTSTUDY_STUDY, cdrVO.getLinkSubjectStudy().getStudy()));
    if (cdrVO.getLinkSubjectStudy().getSubjectUID() != null) {
        criteria.add(Restrictions.ilike("lss." + Constants.LINKSUBJECTSTUDY_SUBJECTUID,
                cdrVO.getLinkSubjectStudy().getSubjectUID(), MatchMode.ANYWHERE));
    }
    if (cdrVO.getLinkSubjectStudy().getSubjectStatus() != null) {
        criteria.add(Restrictions.eq("lss." + Constants.LINKSUBJECTSTUDY_SUBJECTSTATUS,
                cdrVO.getLinkSubjectStudy().getSubjectStatus()));
    }

    // we are dealing with study-level consent
    if (cdrVO.getConsentStatus() != null) {
        if (cdrVO.getConsentStatus().getName().equals(Constants.NOT_CONSENTED)) {
            // Special-case: Treat the null FK for consentStatus as "Not Consented"
            criteria.add(Restrictions.or(
                    Restrictions.eq("lss." + Constants.LINKSUBJECTSTUDY_CONSENTSTATUS,
                            cdrVO.getConsentStatus()),
                    Restrictions.isNull(Constants.LINKSUBJECTSTUDY_CONSENTSTATUS)));
        } else {
            criteria.add(Restrictions.eq("lss." + Constants.LINKSUBJECTSTUDY_CONSENTSTATUS,
                    cdrVO.getConsentStatus()));
        }
    }
    if (cdrVO.getConsentDate() != null) {
        criteria.add(Restrictions.eq("lss." + Constants.LINKSUBJECTSTUDY_CONSENTDATE, cdrVO.getConsentDate()));
    }

    criteria.createAlias("lss.consentStatus", "cs", JoinType.LEFT_OUTER_JOIN);
    criteria.createAlias("lss.subjectStatus", "ss");
    criteria.createAlias("lss.person", "p");
    criteria.createAlias("lss.person.genderType", "genderType");

    // Restrict any addresses to the preferred mailing address
    //Criteria addressCriteria = 
    criteria.createAlias("lss.person.addresses", "a", JoinType.LEFT_OUTER_JOIN);
    //      addressCriteria.setMaxResults(1);
    //      addressCriteria.add(Restrictions.or(Restrictions.or(Restrictions.eq("a.preferredMailingAddress", true), Restrictions.isNull("a.preferredMailingAddress"),Restrictions.eq("a.preferredMailingAddress", false))));

    criteria.createAlias("lss.person.addresses.country", "c", JoinType.LEFT_OUTER_JOIN);
    criteria.createAlias("lss.person.addresses.state", "state", JoinType.LEFT_OUTER_JOIN);
    criteria.createAlias("lss.person.phones", "phone", JoinType.LEFT_OUTER_JOIN);

    //TODO: Get work phone returned as well
    //Criteria phoneCriteria = 
    criteria.createAlias("lss.person.phones.phoneType", "phoneType", JoinType.LEFT_OUTER_JOIN);/*.add(
                                                                                               Restrictions.or(Restrictions.eq("phoneType.name", "Home"),
                                                                                               (
                                                                                               Restrictions.or(Restrictions.or(Restrictions.eq("phoneType.name", "Home"),
                                                                                               Restrictions.isNull("phoneType.name"),Restrictions.eq("phoneType.name", "Mobile")))
                                                                                                       
                                                                                               )
                                                                                               )
                                                                                               ));*/
    //phoneCriteria.setMaxResults(1);
    criteria.createAlias("lss.person.titleType", "title");

    ProjectionList projectionList = Projections.projectionList();
    projectionList.add(Projections.property("lss.subjectUID"), "subjectUID");
    projectionList.add(Projections.property("cs.name"), "consentStatus");
    projectionList.add(Projections.property("ss.name"), "subjectStatus");
    projectionList.add(Projections.property("title.name"), "title");
    projectionList.add(Projections.property("p.firstName"), "firstName");
    projectionList.add(Projections.property("p.lastName"), "lastName");
    projectionList.add(Projections.property("a.streetAddress"), "streetAddress");
    projectionList.add(Projections.property("a.city"), "suburb");
    projectionList.add(Projections.property("a.postCode"), "postcode");
    projectionList.add(Projections.property("state.name"), "state");
    projectionList.add(Projections.property("c.name"), "country");
    projectionList.add(Projections.property("phone.phoneNumber"), "homePhone");
    projectionList.add(Projections.property("p.preferredEmail"), "email");
    projectionList.add(Projections.property("genderType.name"), "sex");
    projectionList.add(Projections.property("lss.consentDate"), "consentDate");

    criteria.setProjection(projectionList); // only return fields required for report

    criteria.addOrder(Order.asc("lss.consentStatus")); // although MySQL causes NULLs to come first
    criteria.addOrder(Order.asc("lss.subjectUID"));

    criteria.setResultTransformer(Transformers.aliasToBean(ConsentDetailsDataRow.class));
    resultList = (criteria.list());

    return resultList;
}

From source file:au.org.theark.report.model.dao.ReportDao.java

License:Open Source License

public List<ConsentDetailsDataRow> getStudyLevelConsentOtherIDDetailsDataRowList(ConsentDetailsReportVO cdrVO) {
    List<ConsentDetailsDataRow> resultList = new ArrayList<ConsentDetailsDataRow>(0);

    Criteria criteria = getSession().createCriteria(LinkSubjectStudy.class, "lss");
    // Add study in context to criteria first (linkSubjectStudy on the VO should never be null)
    criteria.add(//www . jav  a 2s.c  o m
            Restrictions.eq("lss." + Constants.LINKSUBJECTSTUDY_STUDY, cdrVO.getLinkSubjectStudy().getStudy()));
    if (cdrVO.getLinkSubjectStudy().getSubjectUID() != null) {
        criteria.add(Restrictions.ilike("lss." + Constants.LINKSUBJECTSTUDY_SUBJECTUID,
                cdrVO.getLinkSubjectStudy().getSubjectUID(), MatchMode.ANYWHERE));
    }
    if (cdrVO.getLinkSubjectStudy().getSubjectStatus() != null) {
        criteria.add(Restrictions.eq("lss." + Constants.LINKSUBJECTSTUDY_SUBJECTSTATUS,
                cdrVO.getLinkSubjectStudy().getSubjectStatus()));
    }

    // we are dealing with study-level consent
    if (cdrVO.getConsentStatus() != null) {
        if (cdrVO.getConsentStatus().getName().equals(Constants.NOT_CONSENTED)) {
            // Special-case: Treat the null FK for consentStatus as "Not Consented"
            criteria.add(Restrictions.or(
                    Restrictions.eq("lss." + Constants.LINKSUBJECTSTUDY_CONSENTSTATUS,
                            cdrVO.getConsentStatus()),
                    Restrictions.isNull(Constants.LINKSUBJECTSTUDY_CONSENTSTATUS)));
        } else {
            criteria.add(Restrictions.eq("lss." + Constants.LINKSUBJECTSTUDY_CONSENTSTATUS,
                    cdrVO.getConsentStatus()));
        }
    }
    if (cdrVO.getConsentDate() != null) {
        criteria.add(Restrictions.eq("lss." + Constants.LINKSUBJECTSTUDY_CONSENTDATE, cdrVO.getConsentDate()));
    }

    criteria.createAlias("lss.consentStatus", "cs", JoinType.LEFT_OUTER_JOIN);
    criteria.createAlias("lss.subjectStatus", "ss");
    criteria.createAlias("lss.person", "p");
    criteria.createAlias("lss.person.genderType", "genderType");

    // Restrict any addresses to the preferred mailing address
    //Criteria addressCriteria = 
    criteria.createAlias("lss.person.addresses", "a", JoinType.LEFT_OUTER_JOIN);
    //      addressCriteria.setMaxResults(1);
    //      addressCriteria.add(Restrictions.or(Restrictions.or(Restrictions.eq("a.preferredMailingAddress", true), Restrictions.isNull("a.preferredMailingAddress"),Restrictions.eq("a.preferredMailingAddress", false))));

    criteria.createAlias("lss.person.addresses.country", "c", JoinType.LEFT_OUTER_JOIN);
    criteria.createAlias("lss.person.addresses.state", "state", JoinType.LEFT_OUTER_JOIN);
    criteria.createAlias("lss.person.phones", "phone", JoinType.LEFT_OUTER_JOIN);

    //TODO: Get work phone returned as well
    //Criteria phoneCriteria = 
    criteria.createAlias("lss.person.phones.phoneType", "phoneType", JoinType.LEFT_OUTER_JOIN);/*.add(
                                                                                               Restrictions.or(Restrictions.eq("phoneType.name", "Home"),
                                                                                               (
                                                                                               Restrictions.or(Restrictions.or(Restrictions.eq("phoneType.name", "Home"),
                                                                                               Restrictions.isNull("phoneType.name"),Restrictions.eq("phoneType.name", "Mobile")))
                                                                                                       
                                                                                               )
                                                                                               )
                                                                                               ));*/
    //phoneCriteria.setMaxResults(1);
    criteria.createAlias("lss.person.titleType", "title");

    ProjectionList projectionList = Projections.projectionList();
    projectionList.add(Projections.property("lss.subjectUID"), "subjectUID");
    projectionList.add(Projections.property("cs.name"), "consentStatus");
    projectionList.add(Projections.property("ss.name"), "subjectStatus");
    projectionList.add(Projections.property("title.name"), "title");
    projectionList.add(Projections.property("p.firstName"), "firstName");
    projectionList.add(Projections.property("p.lastName"), "lastName");
    projectionList.add(Projections.property("a.streetAddress"), "streetAddress");
    projectionList.add(Projections.property("a.city"), "suburb");
    projectionList.add(Projections.property("a.postCode"), "postcode");
    projectionList.add(Projections.property("state.name"), "state");
    projectionList.add(Projections.property("c.name"), "country");
    projectionList.add(Projections.property("phone.phoneNumber"), "homePhone");
    projectionList.add(Projections.property("p.preferredEmail"), "email");
    projectionList.add(Projections.property("genderType.name"), "sex");
    projectionList.add(Projections.property("lss.consentDate"), "consentDate");

    criteria.setProjection(projectionList); // only return fields required for report

    criteria.addOrder(Order.asc("lss.consentStatus")); // although MySQL causes NULLs to come first
    criteria.addOrder(Order.asc("lss.subjectUID"));

    criteria.setResultTransformer(Transformers.aliasToBean(ConsentDetailsDataRow.class));
    resultList = (criteria.list());

    //removing duplicate entries from resultList

    List<ConsentDetailsDataRow> uniqueResults = new ArrayList();

    Iterator<ConsentDetailsDataRow> iterator = resultList.iterator();

    while (iterator.hasNext()) {
        ConsentDetailsDataRow o = iterator.next();
        if (!uniqueResults.contains(o))
            uniqueResults.add(o);
    }

    resultList.clear();
    resultList.addAll(uniqueResults);

    for (int j = 0; j < resultList.size(); j++) {
        ConsentDetailsDataRow c = resultList.get(j);
        if (c.getOtherID() == null && c.getOtherIDSource() == null) {
            List<OtherID> otherIDs = null;
            try {
                otherIDs = iArkCommonService.getOtherIDs(iArkCommonService
                        .getSubjectByUID(c.getSubjectUID(), cdrVO.getLinkSubjectStudy().getStudy())
                        .getPerson());
                if (otherIDs.size() >= 1) {
                    c.setOtherID(otherIDs.get(0).getOtherID());
                    c.setOtherIDSource(otherIDs.get(0).getOtherID_Source());
                }
                if (otherIDs.size() > 1) {
                    for (int i = 1; i < otherIDs.size(); i++) {
                        OtherID o = otherIDs.get(i);
                        ConsentDetailsDataRow clone = new ConsentDetailsDataRow(c.getSubjectUID(),
                                o.getOtherID_Source(), o.getOtherID(), null, null, null, null, null, null, null,
                                null, null, null, null, null, null, null, null);
                        resultList.add(clone);
                    }
                }
            } catch (EntityNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }
    return resultList;
}

From source file:au.org.theark.report.model.dao.ReportDao.java

License:Open Source License

public List<ConsentDetailsDataRow> getStudyCompConsentList(ConsentDetailsReportVO cdrVO) {
    // NB: There should only ever be one Consent record for a particular Subject for a particular StudyComp

    List<ConsentDetailsDataRow> results = new ArrayList<ConsentDetailsDataRow>();
    Criteria criteria = getSession().createCriteria(LinkSubjectStudy.class, "lss");
    ProjectionList projectionList = Projections.projectionList();
    projectionList.add(Projections.property("lss." + "subjectUID"), "subjectUID");

    criteria.add(// w w  w .j a v a2 s .  co  m
            Restrictions.eq("lss." + Constants.LINKSUBJECTSTUDY_STUDY, cdrVO.getLinkSubjectStudy().getStudy()));
    if (cdrVO.getLinkSubjectStudy().getSubjectUID() != null) {
        criteria.add(Restrictions.ilike("lss." + Constants.LINKSUBJECTSTUDY_SUBJECTUID,
                cdrVO.getLinkSubjectStudy().getSubjectUID(), MatchMode.ANYWHERE));
    }
    if (cdrVO.getLinkSubjectStudy().getSubjectStatus() != null) {
        criteria.add(Restrictions.eq("lss." + Constants.LINKSUBJECTSTUDY_SUBJECTSTATUS,
                cdrVO.getLinkSubjectStudy().getSubjectStatus()));
    }

    if (cdrVO.getConsentDate() != null) {
        // NB: constraint on consentDate or consentStatus automatically removes "Not Consented" state
        // So LinkSubjectStudy inner join to Consent ok for populated consentDate
        criteria.createAlias("lss." + Constants.LINKSUBJECTSTUDY_CONSENT, "c");
        criteria.createAlias("c." + Constants.CONSENT_CONSENTSTATUS, "cs");
        // constrain on studyComp
        criteria.add(Restrictions.eq("c." + Constants.CONSENT_STUDYCOMP, cdrVO.getStudyComp()));
        // constrain on consentDate
        criteria.add(Restrictions.eq("c." + Constants.CONSENT_CONSENTDATE, cdrVO.getConsentDate()));
        // ConsentStatus is optional for this query...
        if (cdrVO.getConsentStatus() != null) {
            criteria.add(Restrictions.eq("c." + Constants.CONSENT_CONSENTSTATUS, cdrVO.getConsentStatus()));
        }
        projectionList.add(Projections.property("cs.name"), "consentStatus");
        projectionList.add(Projections.property("c." + Constants.CONSENT_CONSENTDATE), "consentDate");

    } else if (cdrVO.getConsentStatus() != null) {
        if (cdrVO.getConsentStatus().getName().equals(Constants.NOT_CONSENTED)) {
            // Need to handle "Not Consented" status differently (since it doesn't have a Consent record)
            // Helpful website: http://www.cereslogic.com/pages/2008/09/22/hibernate-criteria-subqueries-exists/

            // Build subquery to find all Consent records for a Study Comp
            DetachedCriteria consentCriteria = DetachedCriteria.forClass(Consent.class, "c");
            // Constrain on StudyComponent
            consentCriteria.add(Restrictions.eq("c." + Constants.CONSENT_STUDYCOMP, cdrVO.getStudyComp()));
            // Just in case "Not Consented" is erroneously entered into a row in the Consent table
            // consentCriteria.add(Restrictions.ne("c." + Constants.CONSENT_CONSENTSTATUS, cdrVO.getConsentStatus()));
            // Join LinkSubjectStudy and Consent on ID FK
            consentCriteria.add(Property.forName("c.linkSubjectStudy.id").eqProperty("lss." + "id"));
            criteria.add(Subqueries.notExists(consentCriteria.setProjection(Projections.property("c.id"))));

            // If Consent records follows design for "Not Consented", then:
            // - consentStatus and consentDate are not populated
        } else {
            // NB: constraint on consentDate or consentStatus automatically removes "Not Consented" state
            // So LinkSubjectStudy inner join to Consent ok for all recordable consentStatus
            criteria.createAlias("lss." + Constants.LINKSUBJECTSTUDY_CONSENT, "c");
            criteria.createAlias("c." + Constants.CONSENT_CONSENTSTATUS, "cs");
            // Constrain on StudyComponent
            criteria.add(Restrictions.eq("c." + Constants.CONSENT_STUDYCOMP, cdrVO.getStudyComp()));
            // ConsentStatus is NOT optional for this query!
            criteria.add(Restrictions.eq("c." + Constants.CONSENT_CONSENTSTATUS, cdrVO.getConsentStatus()));
            if (cdrVO.getConsentDate() != null) {
                criteria.add(Restrictions.eq("c." + Constants.CONSENT_CONSENTDATE, cdrVO.getConsentDate()));
            }
            projectionList.add(Projections.property("cs.name"), "consentStatus");
            projectionList.add(Projections.property("c." + Constants.CONSENT_CONSENTDATE), "consentDate");
        }
    } else {
        // Should not attempt to run this query with no consentDate nor consentStatus criteria provided
        log.error(
                "reportDao.getStudyCompConsentList(..) is missing consentDate or consentStatus parameters in the VO");
        return null;
    }

    criteria.addOrder(Order.asc("lss." + "subjectUID"));
    criteria.setProjection(projectionList);
    criteria.setResultTransformer(Transformers.aliasToBean(ConsentDetailsDataRow.class));
    // This gives a list of subjects matching the specific studyComp and consentStatus
    results = criteria.list();

    return results;
}