Skip to content

Instantly share code, notes, and snippets.

@edalquist
Created January 23, 2012 22:16
Show Gist options
  • Select an option

  • Save edalquist/1665818 to your computer and use it in GitHub Desktop.

Select an option

Save edalquist/1665818 to your computer and use it in GitHub Desktop.
protected CriteriaQuery<LoginAggregationImpl> buildFindLoginAggregationsByDateRangeQuery(final CriteriaBuilder cb) {
final CriteriaQuery<LoginAggregationImpl> criteriaQuery = cb.createQuery(LoginAggregationImpl.class);
final Root<DateDimensionImpl> root = criteriaQuery.from(DateDimensionImpl.class);
final CollectionJoin<DateDimensionImpl, LoginAggregationImpl> loginAggrJoin = root.join(DateDimensionImpl_.loginAggregations, JoinType.LEFT);
criteriaQuery.select(loginAggrJoin);
criteriaQuery.where(
cb.and(
cb.between(root.get(DateDimensionImpl_.date), this.startDate, this.endDate),
cb.equal(loginAggrJoin.get(LoginAggregationImpl_.interval), this.intervalParameter),
cb.equal(loginAggrJoin.get(LoginAggregationImpl_.aggregatedGroup), this.aggregatedGroupParameter)
)
);
criteriaQuery.orderBy(cb.desc(root.get(DateDimensionImpl_.date)));
return criteriaQuery;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment