The Car
entity is mapped to a database table with 2 columns: ID
and Color
.
CarDao
has the following method:
Map<Color, Integer> countByColor();
If we have 3 red cars and 2 blue cars in the database table, the method returns a map with 2 keys (red and blue) and the corresponding count (3 resp. 2).
I would like to do this with the Criteria API. What would the method look like? It’s the Map part that worries me.
Thanks.