List of usage examples for org.hibernate.criterion ProjectionList add
public ProjectionList add(Projection projection)
From source file:org.iternine.jeppetto.dao.hibernate.HibernateQueryModelDAO.java
License:Apache License
private Criteria buildCriteria(QueryModel queryModel) { Criteria criteria = getCurrentSession().createCriteria(persistentClass); if (queryModel.getConditions() != null) { for (Condition condition : queryModel.getConditions()) { criteria.add((Criterion) condition.getConstraint()); }/*w ww . ja v a2 s. c o m*/ } for (Map.Entry<String, List<Condition>> associationCriteriaEntry : queryModel.getAssociationConditions() .entrySet()) { Criteria associationCriteria = criteria.createCriteria(associationCriteriaEntry.getKey()); criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); for (Condition condition : associationCriteriaEntry.getValue()) { associationCriteria.add((Criterion) condition.getConstraint()); } } if (queryModel.getProjection() != null) { ProjectionList projectionList = Projections.projectionList(); projectionList.add((org.hibernate.criterion.Projection) queryModel.getProjection().getDetails()); criteria.setProjection(projectionList); } return criteria; }
From source file:org.jasig.ssp.dao.CaseloadDao.java
License:Apache License
@SuppressWarnings("unchecked") public PagingWrapper<PersonSearchResult2> caseLoadFor(final ProgramStatus programStatus, @NotNull final Person coach, final SortingAndPaging sAndP) { // This creation of the query is order sensitive as 2 queries are run // with the same restrictions. The first query simply runs the query to // find a count of the records. The second query returns the row data. // protected Criteria createCriteria() { // return sessionFactory.getCurrentSession().createCriteria( // this.persistentClass); // }/*from ww w . j a v a 2 s. c o m*/ final Criteria query = this.createCriteria(); // Restrict by program status if provided if (programStatus != null) { final Criteria subquery = query.createAlias("programStatuses", "personProgramStatus"); subquery.add(Restrictions.or(Restrictions.isNull("personProgramStatus.expirationDate"), Restrictions.ge("personProgramStatus.expirationDate", new Date()))); subquery.add(Restrictions.eq("personProgramStatus.programStatus", programStatus)); } // restrict to coach query.add(Restrictions.eq("coach", coach)); if (sAndP.getStatus() != null) { query.add(Restrictions.eq("objectStatus", sAndP.getStatus())); } // item count Long totalRows = 0L; if ((sAndP != null) && sAndP.isPaged()) { totalRows = (Long) query.setProjection(Projections.rowCount()).uniqueResult(); } // clear the row count projection query.setProjection(null); // // Add Properties to return in the case load // // Set Columns to Return: id, firstName, middleName, lastName, // schoolId, and birthDate final ProjectionList projections = Projections.projectionList(); projections.add(Projections.property("id").as("clr_personId")); projections.add(Projections.property("firstName").as("clr_firstName")); projections.add(Projections.property("middleName").as("clr_middleName")); projections.add(Projections.property("lastName").as("clr_lastName")); projections.add(Projections.property("schoolId").as("clr_schoolId")); projections.add(Projections.property("studentIntakeCompleteDate").as("clr_studentIntakeCompleteDate")); projections.add(Projections.property("birthDate").as("clr_birthDate")); // Join to Student Type query.createAlias("studentType", "studentType", JoinType.LEFT_OUTER_JOIN); // add StudentTypeName Column projections.add(Projections.property("studentType.name").as("clr_studentTypeName")); projections.add(Projections.property("primaryEmailAddress").as("clr_primaryEmailAddress")); query.setProjection(projections); query.setResultTransformer(new NamespacedAliasToBeanResultTransformer(PersonSearchResult2.class, "clr_")); // Add Paging if (sAndP != null) { sAndP.addAll(query); } return new PagingWrapper<PersonSearchResult2>(totalRows, query.list()); }
From source file:org.jasig.ssp.dao.CaseloadDao.java
License:Apache License
private PagingWrapper<CoachCaseloadRecordCountForProgramStatus> caseloadCountsByStatusWithDateRestrictions( Criterion dateRestrictions, List<UUID> studentTypeIds, List<UUID> serviceReasonIds, List<UUID> specialServiceGroupIds, String homeDepartment, SortingAndPaging sAndP) { final Criteria query = createCriteria(); query.createAlias("programStatuses", "ps").createAlias("coach", "c"); if (dateRestrictions != null) { query.add(dateRestrictions);//from w ww . j av a 2 s .c om } if (studentTypeIds != null && !studentTypeIds.isEmpty()) { query.add(Restrictions.in("studentType.id", studentTypeIds)); } if (serviceReasonIds != null && !serviceReasonIds.isEmpty()) { query.createAlias("serviceReasons", "serviceReasons"); query.createAlias("serviceReasons.serviceReason", "serviceReason"); query.add(Restrictions.in("serviceReason.id", serviceReasonIds)); query.add(Restrictions.eq("serviceReasons.objectStatus", ObjectStatus.ACTIVE)); } if (specialServiceGroupIds != null && !specialServiceGroupIds.isEmpty()) { query.createAlias("specialServiceGroups", "personSpecialServiceGroups").add( Restrictions.in("personSpecialServiceGroups.specialServiceGroup.id", specialServiceGroupIds)); query.add(Restrictions.eq("personSpecialServiceGroups.objectStatus", ObjectStatus.ACTIVE)); } if (homeDepartment == null || homeDepartment.length() <= 0) query.createAlias("coach.staffDetails", "sd", JoinType.LEFT_OUTER_JOIN); else { query.createAlias("coach.staffDetails", "sd"); query.add(Restrictions.eq("sd.departmentName", homeDepartment)); } ProjectionList projectionList = Projections.projectionList() .add(Projections.groupProperty("c.id").as("coachId")); // TODO find a way to turn these into more generic and centralized // feature checks on the Dialect so we at least aren't scattering // Dialect-specific code all over the place Dialect dialect = ((SessionFactoryImplementor) sessionFactory).getDialect(); if (dialect instanceof SQLServerDialect) { // sql server requires all these to part of the grouping projectionList.add(Projections.groupProperty("c.lastName").as("coachLastName")) .add(Projections.groupProperty("c.firstName").as("coachFirstName")) .add(Projections.groupProperty("c.middleName").as("coachMiddleName")) .add(Projections.groupProperty("c.schoolId").as("coachSchoolId")) .add(Projections.groupProperty("c.username").as("coachUsername")); } else { // other dbs (postgres) don't need these in the grouping projectionList.add(Projections.property("c.lastName").as("coachLastName")) .add(Projections.property("c.firstName").as("coachFirstName")) .add(Projections.property("c.middleName").as("coachMiddleName")) .add(Projections.property("c.schoolId").as("coachSchoolId")) .add(Projections.property("c.username").as("coachUsername")); } projectionList.add(Projections.groupProperty("sd.departmentName").as("coachDepartmentName")) .add(Projections.groupProperty("ps.programStatus.id").as("programStatusId")) .add(Projections.count("ps.programStatus.id").as("count")); query.setProjection(projectionList); if (sAndP == null || !(sAndP.isSorted())) { // there are assumptions in CaseloadServiceImpl about this // default ordering... make sure it stays synced up query.addOrder(Order.asc("c.lastName")).addOrder(Order.asc("c.firstName")) .addOrder(Order.asc("c.middleName")); // can't sort on program status name without another join, but // sorting on id is non-deterministic across dbs (sqlserver sorts // UUIDs one way, Postgres another, so you can't write a single // integration test for both), so more dialect specific magic here. if (dialect instanceof SQLServerDialect) { query.addOrder(OrderAsString.asc("ps.programStatus.id")); } else { query.addOrder(Order.asc("ps.programStatus.id")); } } if (sAndP != null) { sAndP.addAll(query); } query.setResultTransformer( new AliasToBeanResultTransformer(CoachCaseloadRecordCountForProgramStatus.class)); // item count Long totalRows = 0L; if ((sAndP != null) && sAndP.isPaged()) { query.setProjection(new MultipleCountProjection("c.id;ps.programStatus.id").setDistinct()); totalRows = (Long) query.uniqueResult(); if (totalRows == 0) { Collection<CoachCaseloadRecordCountForProgramStatus> empty = Lists.newArrayListWithCapacity(0); return new PagingWrapper<CoachCaseloadRecordCountForProgramStatus>(0, empty); } // clear the row count projection query.setProjection(null); } return sAndP == null ? new PagingWrapper<CoachCaseloadRecordCountForProgramStatus>(query.list()) : new PagingWrapper<CoachCaseloadRecordCountForProgramStatus>(totalRows, query.list()); }
From source file:org.jasig.ssp.dao.EarlyAlertDao.java
License:Apache License
private Map<UUID, Number> getCountOfAlertsForPeopleId(@NotNull final Collection<UUID> personIds, CriteriaCallback criteriaCallback) { // validate//from ww w . ja v a 2 s. co m if (personIds == null) { throw new IllegalArgumentException("Must include a collection of personIds (students)."); } // setup return value final Map<UUID, Number> countForPeopleId = Maps.newHashMap(); // only run the query to fill the return Map if values were given if (!personIds.isEmpty()) { BatchProcessor<UUID, Object[]> processor = new BatchProcessor<UUID, Object[]>(personIds); do { Criteria query = createCriteria(); final ProjectionList projections = Projections.projectionList(); projections.add(Projections.groupProperty("person.id").as("personId")); projections.add(Projections.count("id")); query.setProjection(projections); query.add(Restrictions.eq("objectStatus", ObjectStatus.ACTIVE)); if (criteriaCallback != null) { query = criteriaCallback.criteria(query); } processor.process(query, "person.id"); } while (processor.moreToProcess()); // run query @SuppressWarnings("unchecked") final List<Object[]> results = processor.getSortedAndPagedResultsAsList(); // put query results into return value for (final Object[] result : results) { countForPeopleId.put((UUID) result[0], (Number) result[1]); } // ensure all people IDs that were request exist in return Map for (final UUID id : personIds) { if (!countForPeopleId.containsKey(id)) { countForPeopleId.put(id, 0); } } } return countForPeopleId; }
From source file:org.jasig.ssp.dao.EarlyAlertDao.java
License:Apache License
@SuppressWarnings("unchecked") public PagingWrapper<EarlyAlertStudentReportTO> getStudentsEarlyAlertCountSetForCriteria( EarlyAlertStudentSearchTO criteriaTO, SortingAndPaging sAndP) { final Criteria query = createCriteria(); setPersonCriteria(query.createAlias("person", "person"), criteriaTO.getAddressLabelSearchTO()); if (criteriaTO.getTermCode() != null) { query.add(Restrictions.eq("courseTermCode", criteriaTO.getTermCode())); }/* w ww. j a va 2 s. c o m*/ if (criteriaTO.getStartDate() != null) { query.add(Restrictions.ge("createdDate", criteriaTO.getStartDate())); } if (criteriaTO.getEndDate() != null) { query.add(Restrictions.le("createdDate", criteriaTO.getEndDate())); } query.setProjection(null); List<UUID> ids = query.setProjection(Projections.distinct(Projections.property("id"))).list(); if (ids.size() <= 0) { return null; } BatchProcessor<UUID, EarlyAlertStudentReportTO> processor = new BatchProcessor<UUID, EarlyAlertStudentReportTO>( ids, sAndP); do { final Criteria criteria = createCriteria(); ProjectionList projections = Projections.projectionList() .add(Projections.countDistinct("id").as("earlyalert_total")) .add(Projections.countDistinct("closedBy").as("earlyalert_closed")); addBasicStudentProperties(projections, criteria); projections.add(Projections.groupProperty("id").as("earlyalert_earlyAlertId")); criteria.setProjection(projections); criteria.setResultTransformer( new NamespacedAliasToBeanResultTransformer(EarlyAlertStudentReportTO.class, "earlyalert_")); processor.process(criteria, "id"); } while (processor.moreToProcess()); return processor.getSortedAndPagedResults(); }
From source file:org.jasig.ssp.dao.EarlyAlertDao.java
License:Apache License
private ProjectionList addBasicStudentProperties(ProjectionList projections, Criteria criteria) { criteria.createAlias("person", "person"); criteria.createAlias("person.programStatuses", "personProgramStatuses", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("person.coach", "c"); criteria.createAlias("person.staffDetails", "personStaffDetails", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("person.specialServiceGroups", "personSpecialServiceGroups", JoinType.LEFT_OUTER_JOIN); projections.add(Projections.groupProperty("person.firstName").as("earlyalert_firstName")); projections.add(Projections.groupProperty("person.middleName").as("earlyalert_middleName")); projections.add(Projections.groupProperty("person.lastName").as("earlyalert_lastName")); projections.add(Projections.groupProperty("person.schoolId").as("earlyalert_schoolId")); projections/* w w w .ja v a 2s .c o m*/ .add(Projections.groupProperty("person.primaryEmailAddress").as("earlyalert_primaryEmailAddress")); projections.add( Projections.groupProperty("person.secondaryEmailAddress").as("earlyalert_secondaryEmailAddress")); projections.add(Projections.groupProperty("person.cellPhone").as("earlyalert_cellPhone")); projections.add(Projections.groupProperty("person.homePhone").as("earlyalert_homePhone")); projections.add(Projections.groupProperty("person.addressLine1").as("earlyalert_addressLine1")); projections.add(Projections.groupProperty("person.addressLine2").as("earlyalert_addressLine2")); projections.add(Projections.groupProperty("person.city").as("earlyalert_city")); projections.add(Projections.groupProperty("person.state").as("earlyalert_state")); projections.add(Projections.groupProperty("person.zipCode").as("earlyalert_zipCode")); projections.add(Projections.groupProperty("person.id").as("earlyalert_id")); criteria.createAlias("personSpecialServiceGroups.specialServiceGroup", "specialServiceGroup", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("personProgramStatuses.programStatus", "programStatus", JoinType.LEFT_OUTER_JOIN); projections.add(Projections.groupProperty("personSpecialServiceGroups.objectStatus") .as("earlyalert_specialServiceGroupAssocObjectStatus")); projections.add( Projections.groupProperty("specialServiceGroup.name").as("earlyalert_specialServiceGroupName")); projections.add(Projections.groupProperty("specialServiceGroup.id").as("earlyalert_specialServiceGroupId")); projections.add(Projections.groupProperty("programStatus.name").as("earlyalert_programStatusName")); projections.add(Projections.groupProperty("personProgramStatuses.id").as("earlyalert_programStatusId")); projections.add(Projections.groupProperty("personProgramStatuses.expirationDate") .as("earlyalert_programStatusExpirationDate")); // Join to Student Type criteria.createAlias("person.studentType", "studentType", JoinType.LEFT_OUTER_JOIN); // add StudentTypeName Column projections.add(Projections.groupProperty("studentType.name").as("earlyalert_studentTypeName")); projections.add(Projections.groupProperty("studentType.code").as("earlyalert_studentTypeCode")); Dialect dialect = ((SessionFactoryImplementor) sessionFactory).getDialect(); if (dialect instanceof SQLServerDialect) { // sql server requires all these to part of the grouping // projections.add(Projections.groupProperty("c.id").as("coachId")); projections.add(Projections.groupProperty("c.lastName").as("earlyalert_coachLastName")) .add(Projections.groupProperty("c.firstName").as("earlyalert_coachFirstName")) .add(Projections.groupProperty("c.middleName").as("earlyalert_coachMiddleName")) .add(Projections.groupProperty("c.schoolId").as("earlyalert_coachSchoolId")) .add(Projections.groupProperty("c.username").as("earlyalert_coachUsername")); } else { // other dbs (postgres) don't need these in the grouping // projections.add(Projections.property("c.id").as("coachId")); projections.add(Projections.groupProperty("c.lastName").as("earlyalert_coachLastName")) .add(Projections.groupProperty("c.firstName").as("earlyalert_coachFirstName")) .add(Projections.groupProperty("c.middleName").as("earlyalert_coachMiddleName")) .add(Projections.groupProperty("c.schoolId").as("earlyalert_coachSchoolId")) .add(Projections.groupProperty("c.username").as("earlyalert_coachUsername")); } return projections; }
From source file:org.jasig.ssp.dao.EarlyAlertDao.java
License:Apache License
public List<Triple<String, Long, Long>> getEarlyAlertReasonTypeCountByCriteria(Campus campus, String termCode, Date createdDateFrom, Date createdDateTo, ObjectStatus objectStatus) { final Criteria criteria = createCriteria(); if (termCode != null) { criteria.add(Restrictions.eq("courseTermCode", termCode)); }/* ww w .ja v a2 s . com*/ if (createdDateFrom != null) { criteria.add(Restrictions.ge("createdDate", createdDateFrom)); } if (createdDateTo != null) { criteria.add(Restrictions.le("createdDate", createdDateTo)); } if (campus != null) { criteria.add(Restrictions.eq("campus", campus)); } if (objectStatus != null) { criteria.add(Restrictions.eq("objectStatus", objectStatus)); } criteria.createAlias("earlyAlertReasonIds", "eareasons"); ProjectionList projections = Projections.projectionList().add(Projections.property("eareasons.name")) .add(Projections.countDistinct("person")).add(Projections.count("id")); projections.add(Projections.groupProperty("eareasons.name")); criteria.setProjection(projections); criteria.addOrder(Order.asc("eareasons.name")); final List<Triple<String, Long, Long>> reasonCounts = new ArrayList<>(); for (final Object result : criteria.list()) { Object[] resultReasonCounts = (Object[]) result; reasonCounts.add(new Triple((String) resultReasonCounts[0], (Long) resultReasonCounts[1], (Long) resultReasonCounts[2])); } return reasonCounts; }
From source file:org.jasig.ssp.dao.EarlyAlertDao.java
License:Apache License
@SuppressWarnings("unchecked") public PagingWrapper<EarlyAlertSearchResult> searchEarlyAlert(EarlyAlertSearchForm form) { Criteria criteria = createCriteria(); if (form.getAuthor() != null) { criteria.add(Restrictions.eq("createdBy.id", form.getAuthor().getId())); }/*from w ww. jav a 2s . c o m*/ if (form.getStudent() != null) { criteria.add(Restrictions.eq("person", form.getStudent())); } ProjectionList projections = Projections.projectionList(); criteria.setProjection(projections); projections.add(Projections.property("id").as("earlyAlertId")); projections.add(Projections.property("courseTitle").as("courseTitle")); projections.add(Projections.property("courseName").as("courseName")); projections.add(Projections.property("createdDate").as("createdDate")); projections.add(Projections.property("closedDate").as("closedDate")); projections.add(Projections.property("lastResponseDate").as("lastResponseDate")); projections.add(Projections.property("courseTermCode").as("courseTermCode")); criteria.setResultTransformer(new AliasToBeanResultTransformer(EarlyAlertSearchResult.class)); form.getSortAndPage().addStatusFilterToCriteria(criteria); List<EarlyAlertSearchResult> earlyAlertSearchResults = criteria.list(); List<String> termCodes = new ArrayList<String>(); for (EarlyAlertSearchResult earlyAlertSearchResult : earlyAlertSearchResults) { if (!termCodes.contains(earlyAlertSearchResult.getCourseTermCode())) termCodes.add(earlyAlertSearchResult.getCourseTermCode()); } List<Term> terms = termService.getTermsByCodes(termCodes); Map<String, Term> termMap = new HashMap<String, Term>(); for (Term term : terms) { if (!termMap.containsKey(term.getCode())) termMap.put(term.getCode(), term); } for (EarlyAlertSearchResult earlyAlertSearchResult : earlyAlertSearchResults) { if (StringUtils.isNotBlank(earlyAlertSearchResult.getCourseTermCode())) { Term term = termMap.get(earlyAlertSearchResult.getCourseTermCode()); if (term != null) { earlyAlertSearchResult.setCourseTermName(term.getName()); earlyAlertSearchResult.setCourseTermStartDate(term.getStartDate()); } else { earlyAlertSearchResult.setCourseTermName(earlyAlertSearchResult.getCourseTermCode()); } } earlyAlertSearchResult.setStatus(); } int size = earlyAlertSearchResults.size(); List<EarlyAlertSearchResult> sortedAndPaged = new ArrayList<EarlyAlertSearchResult>(); try { sortedAndPaged = (List<EarlyAlertSearchResult>) (List<?>) form.getSortAndPage() .sortAndPageList((List<Object>) (List<?>) earlyAlertSearchResults); } catch (NoSuchFieldException e) { LOGGER.error("Field not Found", e); } catch (SecurityException e) { LOGGER.error("Field not allowed", e); } catch (ClassNotFoundException e) { LOGGER.error("Class not Found", e); } return new PagingWrapper<EarlyAlertSearchResult>(size, sortedAndPaged); }
From source file:org.jasig.ssp.dao.EarlyAlertResponseDao.java
License:Apache License
@SuppressWarnings({ "unchecked" }) public Collection<EarlyAlertStudentOutreachReportTO> getEarlyAlertOutreachCountByOutcome(String alertTermCode, Date alertCreateDateFrom, Date alertCreateDateTo, Date responseCreateDateFrom, Date responseCreateDateTo, List<UUID> outcomes, String homeDepartment, Person coach) { final Criteria query = createCriteria(); query.createAlias("earlyAlert", "earlyAlert"); if (alertTermCode != null) { query.add(Restrictions.eq("earlyAlert.courseTermCode", alertTermCode)); }/* ww w .j a v a2s. c o m*/ if (alertCreateDateFrom != null) { query.add(Restrictions.ge("earlyAlert.createdDate", alertCreateDateFrom)); } if (alertCreateDateTo != null) { query.add(Restrictions.le("earlyAlert.createdDate", alertCreateDateTo)); } if (responseCreateDateFrom != null) { query.add(Restrictions.ge("createdDate", responseCreateDateFrom)); } if (responseCreateDateTo != null) { query.add(Restrictions.le("createdDate", responseCreateDateTo)); } if (outcomes != null && outcomes.size() > 0) { query.add(Restrictions.in("earlyAlertOutcome.id", outcomes)); } query.createAlias("earlyAlert.person", "student"); Criteria coachCriteria = query.createAlias("student.coach", "coach"); if (coach != null) { coachCriteria.add(Restrictions.eq("coach.id", coach.getId())); } if (homeDepartment != null && homeDepartment.length() > 0) { query.createAlias("coach.staffDetails", "personStaffDetails"); query.add(Restrictions.eq("personStaffDetails.departmentName", homeDepartment)); } else { query.createAlias("coach.staffDetails", "personStaffDetails", JoinType.LEFT_OUTER_JOIN); } ProjectionList projections = Projections.projectionList() .add(Projections.groupProperty("earlyAlert.id").as("ea_outcome_earlyAlertId")); projections.add(Projections.groupProperty("coach.firstName").as("ea_outcome_coachFirstName")); projections.add(Projections.groupProperty("coach.middleName").as("ea_outcome_coachMiddleName")); projections.add(Projections.groupProperty("coach.lastName").as("ea_outcome_coachLastName")); projections.add(Projections.groupProperty("coach.id").as("ea_outcome_coachId")); projections.add(Projections.groupProperty("coach.schoolId").as("ea_outcome_coachSchoolId")); projections.add(Projections.groupProperty("personStaffDetails.departmentName") .as("ea_outcome_coachDepartmentName")); query.createAlias("earlyAlertOutreachIds", "earlyAlertOutreachIds"); projections.add( Projections.groupProperty("earlyAlertOutreachIds.name").as("ea_outcome_earlyAlertOutreachName")); query.setProjection(projections).setResultTransformer( new NamespacedAliasToBeanResultTransformer(EarlyAlertStudentOutreachReportTO.class, "ea_outcome_")); // item count List<EarlyAlertStudentOutreachReportTO> values = query.list(); if (values.size() == 0) { return null; } Iterator<EarlyAlertStudentOutreachReportTO> valueIterator = values.iterator(); ArrayList<EarlyAlertStudentOutreachReportTO> responses = new ArrayList<EarlyAlertStudentOutreachReportTO>(); while (valueIterator.hasNext()) { EarlyAlertStudentOutreachReportTO value = valueIterator.next(); Integer index = responses.indexOf(value); if (index != null && index >= 0) { responses.get(index).processDuplicate(value); } else { responses.add(value); } } return responses; }
From source file:org.jasig.ssp.dao.EarlyAlertResponseDao.java
License:Apache License
@SuppressWarnings({ "unchecked", "unused" }) public List<EarlyAlertStudentResponseOutcomeReportTO> getEarlyAlertResponseOutcomeTypeForStudentsByCriteria( String outcomeType, EarlyAlertStudentSearchTO searchForm, SortingAndPaging sAndP) { final Criteria criteria = getCriteriaForOutcomeType(searchForm, sAndP); ProjectionList projections = getPersonProjection(); criteria.createAlias(outcomeType, outcomeType); projections.add(Projections.groupProperty(outcomeType + ".name").as("ea_outcome_outcomeName")); criteria.setProjection(projections).setResultTransformer(new NamespacedAliasToBeanResultTransformer( EarlyAlertStudentResponseOutcomeReportTO.class, "ea_outcome_")); return (List) criteria.list(); }