How are the two following CriteriaBuilder methods used? Have you ever used them or seen them used in a real world application? I can't find an example on the web. Reading the code comments: values and keys creates an collection expression that can be passed to size(), isMember(), etc.
//get the values and keys collections of the Map, which may then
//be passed to size(), isMember(), isEmpty(), etc
/**
* Create an expression that returns the values of a map.
*
* @param map map
*
* @return collection expression
*/
<V, M extends Map<?, V>> Expression<Collection<V>> values(M map);
/**
* Create an expression that returns the keys of a map.
*
* @param map map
*
* @return set expression
*/
<K, M extends Map<K, ?>> Expression<Set<K>> keys(M map);
But why would JPA be needed to determine the size of a collection, or to test whether an element is a member of a collection? It seems that this can be done in Java, no need for JPA.