EntityGraph - You must define a fetch group manager at descriptor in order to set a fetch group on the query

谁都会走 提交于 2020-06-23 06:48:32

问题


I would like use Entity Graphs in EclipseLink and GlassFish.

    @Entity
    @NamedQueries({
         @NamedQuery(name = "invoice.all", query = "SELECT i FROM Invoice i")})


    @NamedEntityGraph(name = "graph.invoice",
                attributeNodes = {@NamedAttributeNode("invoiceNum")})

    @Table(name = "INVOICE")
    public class Invoice implements Serializable {
            private int id;
            private String bizonylatSzam;
            ...
        }

EntityManager em = getEntityManagerFactory().createEntityManager();
EntityGraph eg = em.createEntityGraph("graph.invoice");
List<Invoice> invoiceList =  em.createNamedQuery("invoice.all").setHint("javax.persistence.fetchgraph", eg).getResultList();

If I use javax.persistence.loadgraph graph everything OK, but if i use javax.persistence.fetchgraph I have an exception:

org.eclipse.persistence.exceptions.QueryException Exception Description: You must define a fetch group manager at descriptor (Invoice) in order to set a fetch group on the query (invoice.all)

In EclipseLink webpage write:

... using Weaving technologi..

Weaving and Java EE Application Servers

The default EclipseLink weaving behavior applies in any Java EE JPA-compliant application server using the EclipseLink JPA persistence provider. To change this behavior, modify your persistence.xml file (for your JPA entities or POJO classes) to use EclipseLink JPA properties, EclipseLink JPA annotations, or both.

I dont understand what is the problem. :(

来源:https://stackoverflow.com/questions/47338358/entitygraph-you-must-define-a-fetch-group-manager-at-descriptor-in-order-to-se

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!