3

EclipseLink: fetch group cannot be set on report query.

    TypedQuery<Q> query = em.createQuery(criteriaQuery);
    query.setHint("javax.persistence.fetchgraph", entityGraph); 
    List results = query.getResultList();

What is report query?

https://docs.oracle.com/cd/B25221_04/web.1013/b13593/errcode006.htm

6112: FETCH_GROUP_NOT_SUPPORT_ON_REPORT_QUERY
Cause: Fetch group cannot be set on report query.
Action: Remove the fetch group setting on ReportQuery, or use ReadObjectQuery or ReadObjectQuery instead.

Thanks.

Dave
  • 759
  • 2
  • 9
  • 31
  • 2
    Raise a bug on EclipseLink for not complying with the JPA 2.1 spec. You should be able to set an EntityGraph on any JPQL query; what the implementation does with it is for it to decide but it CANNOT throw an exception of that nature. – Neil Stockton Jun 25 '16 at 06:22
  • 1
    A report query is one that doesn't return entities. What is your query? – Chris Jun 28 '16 at 13:59
  • 1
    It is a groupBy query and its query result type(selections) is Object[] that includes entities. Fetch group should apply to the entities. – Dave Jun 28 '16 at 19:10
  • Has this been reported? I have a query that returns entities which has a `GROUP BY` on a joined child property, but throws the same exception. Query: `@NamedQuery(name = GroupMember.FIND_BY_GROUP, query = "SELECT gm FROM GroupMember gm JOIN gm.roster ro LEFT JOIN ro.teamMembers tm JOIN ro.team te JOIN te.club cl JOIN gm.group gr JOIN gr.groupLabel gl JOIN gr.round rd WHERE rd.id = :roundId AND gl.code = :groupCode GROUP BY ro.id ORDER BY cl.code, cl.name")` -> this is supposed to return one group member per roster ID, but the child joins return n entities per n team members... – Kawu Jun 10 '20 at 10:51
  • Happens for query `@NamedQuery(name = Game.FIND_ALL_JOIN_SCORES_GROUP_BY_GAME_ID, query = "SELECT ga FROM Game ga JOIN ga.scores sc GROUP BY ga.id")`, see test sample here: https://github.com/kawoolutions/primefaces-test/tree/master/src/main/java/org/eclipselink/test/ccemapfetchgrouptracker – Kawu Jun 15 '20 at 12:38

0 Answers0