I'm doing some weird reporting from a JPA data store.
I need to select (using EJBQL) a list of objects. These objects contain collection of entities. I have a class that is constructed by:
FOOBean(String param1, 
    String param2, 
    List<Entity> listParam)
(notice that third parameter is a list)
And I want to select a list of these beans using GROUP BY, fetching listParam along, so I would like to write a query that works like this: 
      SELECT new FOOBean(
               e1.param1, 
               e1.param2,
               e1) 
               FROM Entity e1
               GROUP BY e1.param1, e1.param2
So that grouped entities are fetched into a list and inserted into the third parameter. Is it possible to do it that way or do I have to create two queries that selects distinct pairs of param1 and param2; and fetches all entities with appropriate param values respectively?