public final class GroupBy extends Object
GroupBy
provides factory methods for ResultTransformer
and GroupExpression
creation
Example: Group employees by department
query.transform(
GroupBy.groupBy(employee.department)
.as(GroupBy.list(Projections.tuple(employee.id, employee.firstName, employee.lastName))))
Modifier and Type | Method and Description |
---|---|
static <E extends Number> |
avg(Expression<E> expression)
Create a new aggregating avg expression
|
static GroupByBuilder<List<?>> |
groupBy(Expression<?>... keys)
Create a new GroupByBuilder for the given key expressions
|
static <K> GroupByBuilder<K> |
groupBy(Expression<K> key)
Create a new GroupByBuilder for the given key expression
|
static <E> AbstractGroupExpression<E,List<E>> |
list(Expression<E> expression)
Create a new aggregating list expression
|
static <E,F> AbstractGroupExpression<E,List<F>> |
list(GroupExpression<E,F> groupExpression)
Create a new aggregating list expression
|
static <K,V> AbstractGroupExpression<com.mysema.commons.lang.Pair<K,V>,Map<K,V>> |
map(Expression<K> key,
Expression<V> value)
Create a new aggregating map expression using a backing LinkedHashMap
|
static <K,V,U> AbstractGroupExpression<com.mysema.commons.lang.Pair<K,V>,Map<K,U>> |
map(Expression<K> key,
GroupExpression<V,U> value)
Create a new aggregating map expression using a backing LinkedHashMap
|
static <K,V,T> AbstractGroupExpression<com.mysema.commons.lang.Pair<K,V>,Map<T,V>> |
map(GroupExpression<K,T> key,
Expression<V> value)
Create a new aggregating map expression using a backing LinkedHashMap
|
static <K,V,T,U> AbstractGroupExpression<com.mysema.commons.lang.Pair<K,V>,Map<T,U>> |
map(GroupExpression<K,T> key,
GroupExpression<V,U> value)
Create a new aggregating map expression using a backing LinkedHashMap
|
static <E extends Comparable<? super E>> |
max(Expression<E> expression)
Create a new aggregating max expression
|
static <E extends Comparable<? super E>> |
min(Expression<E> expression)
Create a new aggregating min expression
|
static <E> AbstractGroupExpression<E,Set<E>> |
set(Expression<E> expression)
Create a new aggregating set expression using a backing LinkedHashSet
|
static <E,F> GroupExpression<E,Set<F>> |
set(GroupExpression<E,F> groupExpression)
Create a new aggregating set expression using a backing LinkedHashSet
|
static <K extends Comparable<? super K>,V> |
sortedMap(Expression<K> key,
Expression<V> value)
Create a new aggregating map expression using a backing TreeMap
|
static <K,V> AbstractGroupExpression<com.mysema.commons.lang.Pair<K,V>,SortedMap<K,V>> |
sortedMap(Expression<K> key,
Expression<V> value,
Comparator<? super K> comparator)
Create a new aggregating map expression using a backing TreeMap using the given comparator
|
static <K extends Comparable<? super K>,V,U> |
sortedMap(Expression<K> key,
GroupExpression<V,U> value)
Create a new aggregating map expression using a backing TreeMap
|
static <K,V,U> AbstractGroupExpression<com.mysema.commons.lang.Pair<K,V>,SortedMap<K,U>> |
sortedMap(Expression<K> key,
GroupExpression<V,U> value,
Comparator<? super K> comparator)
Create a new aggregating map expression using a backing TreeMap using the given comparator
|
static <K,V,T extends Comparable<? super T>> |
sortedMap(GroupExpression<K,T> key,
Expression<V> value)
Create a new aggregating map expression using a backing TreeMap
|
static <K,V,T> AbstractGroupExpression<com.mysema.commons.lang.Pair<K,V>,SortedMap<T,V>> |
sortedMap(GroupExpression<K,T> key,
Expression<V> value,
Comparator<? super T> comparator)
Create a new aggregating map expression using a backing TreeMap using the given comparator
|
static <K,V,T extends Comparable<? super T>,U> |
sortedMap(GroupExpression<K,T> key,
GroupExpression<V,U> value)
Create a new aggregating map expression using a backing TreeMap
|
static <K,V,T,U> AbstractGroupExpression<com.mysema.commons.lang.Pair<K,V>,SortedMap<T,U>> |
sortedMap(GroupExpression<K,T> key,
GroupExpression<V,U> value,
Comparator<? super T> comparator)
Create a new aggregating map expression using a backing TreeMap using the given comparator
|
static <E extends Comparable<? super E>> |
sortedSet(Expression<E> expression)
Create a new aggregating set expression using a backing TreeSet
|
static <E> AbstractGroupExpression<E,SortedSet<E>> |
sortedSet(Expression<E> expression,
Comparator<? super E> comparator)
Create a new aggregating set expression using a backing TreeSet using the given comparator
|
static <E,F extends Comparable<? super F>> |
sortedSet(GroupExpression<E,F> groupExpression)
Create a new aggregating set expression using a backing TreeSet
|
static <E,F> GroupExpression<E,SortedSet<F>> |
sortedSet(GroupExpression<E,F> groupExpression,
Comparator<? super F> comparator)
Create a new aggregating set expression using a backing TreeSet using the given comparator
|
static <E extends Number> |
sum(Expression<E> expression)
Create a new aggregating sum expression
|
public static <K> GroupByBuilder<K> groupBy(Expression<K> key)
key
- key for aggregationpublic static GroupByBuilder<List<?>> groupBy(Expression<?>... keys)
keys
- keys for aggregationpublic static <E extends Comparable<? super E>> AbstractGroupExpression<E,E> min(Expression<E> expression)
expression
- expression for which the minimum value will be used in the group by projectionpublic static <E extends Number> AbstractGroupExpression<E,E> sum(Expression<E> expression)
expression
- expression a for which the accumulated sum will be used in the group by projectionpublic static <E extends Number> AbstractGroupExpression<E,E> avg(Expression<E> expression)
expression
- expression for which the accumulated average value will be used in the group by projectionpublic static <E extends Comparable<? super E>> AbstractGroupExpression<E,E> max(Expression<E> expression)
expression
- expression for which the maximum value will be used in the group by projectionpublic static <E> AbstractGroupExpression<E,List<E>> list(Expression<E> expression)
expression
- values for this expression will be accumulated into a listpublic static <E,F> AbstractGroupExpression<E,List<F>> list(GroupExpression<E,F> groupExpression)
E
- F
- groupExpression
- values for this expression will be accumulated into a listpublic static <E> AbstractGroupExpression<E,Set<E>> set(Expression<E> expression)
expression
- values for this expression will be accumulated into a setpublic static <E,F> GroupExpression<E,Set<F>> set(GroupExpression<E,F> groupExpression)
E
- F
- groupExpression
- values for this expression will be accumulated into a setpublic static <E extends Comparable<? super E>> AbstractGroupExpression<E,SortedSet<E>> sortedSet(Expression<E> expression)
expression
- values for this expression will be accumulated into a setpublic static <E,F extends Comparable<? super F>> GroupExpression<E,SortedSet<F>> sortedSet(GroupExpression<E,F> groupExpression)
groupExpression
- values for this expression will be accumulated into a setpublic static <E> AbstractGroupExpression<E,SortedSet<E>> sortedSet(Expression<E> expression, Comparator<? super E> comparator)
expression
- values for this expression will be accumulated into a setcomparator
- comparator of the created TreeSet instancepublic static <E,F> GroupExpression<E,SortedSet<F>> sortedSet(GroupExpression<E,F> groupExpression, Comparator<? super F> comparator)
groupExpression
- values for this expression will be accumulated into a setcomparator
- comparator of the created TreeSet instancepublic static <K,V> AbstractGroupExpression<com.mysema.commons.lang.Pair<K,V>,Map<K,V>> map(Expression<K> key, Expression<V> value)
key
- key for the map entriesvalue
- value for the map entriespublic static <K,V,T> AbstractGroupExpression<com.mysema.commons.lang.Pair<K,V>,Map<T,V>> map(GroupExpression<K,T> key, Expression<V> value)
key
- key for the map entriesvalue
- value for the map entriespublic static <K,V,U> AbstractGroupExpression<com.mysema.commons.lang.Pair<K,V>,Map<K,U>> map(Expression<K> key, GroupExpression<V,U> value)
key
- key for the map entriesvalue
- value for the map entriespublic static <K,V,T,U> AbstractGroupExpression<com.mysema.commons.lang.Pair<K,V>,Map<T,U>> map(GroupExpression<K,T> key, GroupExpression<V,U> value)
key
- key for the map entriesvalue
- value for the map entriespublic static <K extends Comparable<? super K>,V> AbstractGroupExpression<com.mysema.commons.lang.Pair<K,V>,SortedMap<K,V>> sortedMap(Expression<K> key, Expression<V> value)
key
- key for the map entriesvalue
- value for the map entriespublic static <K,V,T extends Comparable<? super T>> AbstractGroupExpression<com.mysema.commons.lang.Pair<K,V>,SortedMap<T,V>> sortedMap(GroupExpression<K,T> key, Expression<V> value)
key
- key for the map entriesvalue
- value for the map entriespublic static <K extends Comparable<? super K>,V,U> AbstractGroupExpression<com.mysema.commons.lang.Pair<K,V>,SortedMap<K,U>> sortedMap(Expression<K> key, GroupExpression<V,U> value)
key
- key for the map entriesvalue
- value for the map entriespublic static <K,V,T extends Comparable<? super T>,U> AbstractGroupExpression<com.mysema.commons.lang.Pair<K,V>,SortedMap<T,U>> sortedMap(GroupExpression<K,T> key, GroupExpression<V,U> value)
key
- key for the map entriesvalue
- value for the map entriespublic static <K,V> AbstractGroupExpression<com.mysema.commons.lang.Pair<K,V>,SortedMap<K,V>> sortedMap(Expression<K> key, Expression<V> value, Comparator<? super K> comparator)
key
- key for the map entriesvalue
- value for the map entriescomparator
- comparator for the created TreeMap instancespublic static <K,V,T> AbstractGroupExpression<com.mysema.commons.lang.Pair<K,V>,SortedMap<T,V>> sortedMap(GroupExpression<K,T> key, Expression<V> value, Comparator<? super T> comparator)
key
- key for the map entriesvalue
- value for the map entriescomparator
- comparator for the created TreeMap instancespublic static <K,V,U> AbstractGroupExpression<com.mysema.commons.lang.Pair<K,V>,SortedMap<K,U>> sortedMap(Expression<K> key, GroupExpression<V,U> value, Comparator<? super K> comparator)
key
- key for the map entriesvalue
- value for the map entriescomparator
- comparator for the created TreeMap instancespublic static <K,V,T,U> AbstractGroupExpression<com.mysema.commons.lang.Pair<K,V>,SortedMap<T,U>> sortedMap(GroupExpression<K,T> key, GroupExpression<V,U> value, Comparator<? super T> comparator)
key
- key for the map entriesvalue
- value for the map entriescomparator
- comparator for the created TreeMap instancesCopyright © 2007–2016 Querydsl. All rights reserved.