/** * A grouping property value projection * * @param propertyName The name of the property to group * * @return The grouped projection * * @see PropertyProjection */ public static PropertyProjection groupProperty(String propertyName) { return new PropertyProjection( propertyName, true ); }
protected Criteria getCriteria(Session s) { return s.createCriteria( Enrolment.class, "e" ) .setProjection( Projections.property( "e.student" ).as( "student" ) ) .addOrder( Order.asc( "e.studentNumber") ) .setResultTransformer( Transformers.ALIAS_TO_ENTITY_MAP ); } };
protected Criteria getCriteria(Session s) throws Exception { return s.createCriteria( Student.class, "s" ) .setProjection( Projections.property( "s.name" ).as( "name" )) .addOrder( Order.asc( "s.studentNumber" ) ) .setResultTransformer( new AliasToBeanConstructorResultTransformer( getConstructor() ) ); } private Constructor getConstructor() throws NoSuchMethodException {
/** * A property value projection * * @param propertyName The name of the property whose values should be projected * * @return The property projection * * @see PropertyProjection */ public static PropertyProjection property(String propertyName) { return new PropertyProjection( propertyName ); }
protected Criteria getCriteria(Session s) { return s.createCriteria( Enrolment.class, "e" ) .createAlias( "e.student", "st" ) .createAlias( "e.course", "co" ) .setProjection( Projections.property( "st.name" ).as( "studentName" ) ) .addOrder( Order.asc( "st.studentNumber" ) ) .setResultTransformer( Transformers.aliasToBean( StudentDTO.class ) ); } };
/** * A grouping property value */ public static PropertyProjection groupProperty(String propertyName) { return new PropertyProjection(propertyName, true); }
public HibernateRequest<T> proj(String propertyName, String alias) { proj(Projections.property(propertyName).as(alias)); return this; }
/** * A projected property value */ public static PropertyProjection property(String propertyName) { return new PropertyProjection(propertyName); }
public HibernateRequest<T> proj(String propertyName) { proj(Projections.property(propertyName).as(propertyName)); return this; }
/** * A grouping property value */ public static PropertyProjection groupProperty(String propertyName) { return new PropertyProjection(propertyName, true); }
@Override public List<ThesaurusOrganization> getFilteredOrganizationNames() { Criteria criteria = getCurrentSession().createCriteria(Thesaurus.class, "t") .add(Restrictions.isNotNull("t.creator")) .createCriteria("creator", "c", JoinType.RIGHT_OUTER_JOIN) .setProjection( Projections.distinct(Projections.projectionList().add( Projections.property("c.name").as("name")))) .setResultTransformer(Transformers.aliasToBean(ThesaurusOrganization.class)) .addOrder(Order.asc("name")); return criteria.list(); } }
/** * A grouping property value */ public static PropertyProjection groupProperty(String propertyName) { return new PropertyProjection(propertyName, true); }
.projectionList() .add(Projections.property("tt.lexicalValue")) .add(Projections.property("tc.identifier").as( "identifier"))).setResultTransformer( Transformers.aliasToBean(ThesaurusConcept.class));
/** * A projected property value */ public static PropertyProjection property(String propertyName) { return new PropertyProjection(propertyName); }
private Criteria selectPaginatedConceptsByAlphabeticalOrder(Integer startIndex, Integer limit) { Criteria criteria = getCurrentSession() .createCriteria(ThesaurusTerm.class, "tt") .add(Restrictions.isNotNull("tt.concept")) .createCriteria("concept", "tc", JoinType.RIGHT_OUTER_JOIN); criteria.add(Restrictions.eq("tt.prefered", Boolean.TRUE)); criteria.setProjection( Projections .projectionList() .add(Projections.property("tt.lexicalValue")) .add(Projections.property("tc.identifier").as( "identifier"))).setResultTransformer( Transformers.aliasToBean(ThesaurusConcept.class)); if (limit > 0) { criteria.setMaxResults(limit); } criteria.setFirstResult(startIndex); criteria.addOrder(Order.asc("tt.lexicalValue")); return criteria; }
/** * A grouping property value */ public static PropertyProjection groupProperty(String propertyName) { return new PropertyProjection(propertyName, true); }
private List<Event> retrieveGrouped(List<String> eventActions, User user, Date startTime, Date stopTime, Set<Integer> appIds, Set<Integer> teamIds, Set<Integer> vulnIds, Set<Integer> defectIds) { Criteria criteria = getEventCriteria(eventActions, user, startTime, stopTime, appIds, teamIds, vulnIds, defectIds); criteria.setProjection(Projections.projectionList() .add(Projections.count("id").as("groupCount")) .add(Projections.groupProperty("eventAction").as("eventAction")) .add(Projections.groupProperty("scan").as("scan")) .add(Projections.groupProperty("deletedScanId").as("deletedScanId")) .add(Projections.min("date"), "date") .add(Projections.groupProperty("application"), "application") .add(Projections.groupProperty("user"), "user") ); criteria.setResultTransformer(Transformers.aliasToBean(Event.class)); List<Event> events = criteria.list(); for (Event event : events) { EventAction eventAction = event.getEventActionEnum(); EventAction groupedEventAction = eventAction.getGroupedEventAction(); String groupedEventActionString = groupedEventAction.name(); event.setEventAction(groupedEventActionString); } return events; }
/** * A projected property value */ public static PropertyProjection property(String propertyName) { return new PropertyProjection(propertyName); }
private Criteria getCriteriaByThesaurusAndTopConcept(Thesaurus thesaurus, boolean topConcept,String like, ConceptStatusEnum status) { Criteria criteria = getCurrentSession().createCriteria(ThesaurusConcept.class, "tc"); if(null != like){ criteria = getCurrentSession().createCriteria(ThesaurusTerm.class, "tt") .add(Restrictions.isNotNull("tt.concept")) .createCriteria("concept", "tc", JoinType.RIGHT_OUTER_JOIN); criteria.setProjection( Projections .projectionList() .add(Projections.property("tt.lexicalValue")) .add(Projections.property("tc.identifier").as( "identifier"))).setResultTransformer( Transformers.aliasToBean(ThesaurusConcept.class)); conceptNameIsLike(criteria,like); } selectThesaurus(criteria, thesaurus.getIdentifier()); selectOrphans(criteria, !topConcept); selectNoParents(criteria); selectStatus(criteria, status); return criteria; }
/** * A projected property value */ public static PropertyProjection property(String propertyName) { return new PropertyProjection(propertyName); }