Code example for ProjectionList

Methods: add

0
     */ 
    public Criteria getCriteria(final Session hibernateSession)
    { 
        Criteria criteria = hibernateSession.createCriteria(DomainGroup.class);
        ProjectionList fields = Projections.projectionList();
        fields.add(getColumn("id"));
        fields.add(getColumn("description"));
        fields.add(getColumn("name"));
        fields.add(getColumn("shortName"));
        fields.add(Projections.property("publicGroup").as("isPublic"));
        fields.add(getColumn("updatesCount"));
        fields.add(getColumn("followersCount"));
        fields.add(getColumn("dateAdded"));
        fields.add(getColumn("avatarId"));
        fields.add(getColumn("avatarCropSize"));
        fields.add(getColumn("avatarCropX"));
        fields.add(getColumn("avatarCropY"));
        fields.add(getColumn("bannerId"));
        fields.add(getColumn("overview"));
        fields.add(getColumn("commentable"));
        fields.add(getColumn("streamPostable"));
        fields.add(getColumn("url"));
        fields.add(getColumn("stickyActivityId"));
        fields.add(Projections.property("cb.accountId").as("personCreatedByAccountId"));
        fields.add(Projections.property("cb.displayName").as("personCreatedByDisplayName"));
        fields.add(Projections.property("cb.companyName").as("personCreatedByCompanyName"));
        fields.add(Projections.property("stream.id").as("streamId"));
        criteria.setProjection(fields);
        criteria.createAlias("createdBy", "cb");
        criteria.createAlias("streamScope", "stream");
 
        // We don't currently cache pending groups 
        // TODO: this needs to change - we should figure out how to remove this rule 
        criteria.add(Restrictions.eq("isPending", false));
 
        ModelViewResultTransformer<DomainGroupModelView> resultTransformer = //
        new ModelViewResultTransformer<DomainGroupModelView>(new DomainGroupModelViewFactory()); 
        criteria.setResultTransformer(resultTransformer);
 
        return criteria;
    } 
 
    /** 
     * Build the PropertyProjection with alias. 
     * 
     * @param propertyName 
     *            the property name 
     * @return the PropertyProjection with alias 
     */ 
    private Projection getColumn(final String propertyName)
    { 
        return Projections.property(propertyName).as(propertyName);
    } 
} 
Connect your IDE to all the code out there  Get Codota for Java