Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » JPA: EntityGraph -> FetchGroupException [CLOSED](JPA: EntityGraph -> FetchGroupException)
icon3.gif  JPA: EntityGraph -> FetchGroupException [CLOSED] [message #1734453] Wed, 08 June 2016 13:21 Go to next message
Pavel No is currently offline Pavel NoFriend
Messages: 45
Registered: May 2016
Member
I use EclipseLink 2.6.3 as a JPA provider. I have the following code:

String queryString="SELECT a FROM Student a WHERE a.id='"+id+"'";
EntityGraph<Student> eg = em.createEntityGraph(Student.class);
eg.addAttributeNodes("id");
Query query = em.createQuery(queryString);
query.setHint("javax.persistence.fetchgraph", eg);
List<Student> items=query.getResultList();


However, I get exception:
    org.eclipse.persistence.exceptions.QueryException: Exception Description: You must define a fetch group manager at descriptor (com.temp.Student) in order to set a fetch group on the query (null) Query: ReadObjectQuery(referenceClass=Student jpql="SELECT a FROM Student a WHERE a.id='1'") FetchGroup(null){id}


In internet people say that it is necessary to enable weaving, so I added

<property name="eclipselink.weaving" value="true"/>


to my persistence.xml. However, it didn't help. Besides is not clear, why it complains about fetch group while I use fetch graph.

P.S. As I found here http://www.radcortez.com/jpa-entity-graphs/

Before JPA 2.1, the implementations already supported a non standard
way to load data similar to Entity Graphs. You have Hibernate Fetch
Profiles, OpenJPA Fetch Groups and EclipseLink Fetch Groups. It was
logical to have this kind of behaviour in the specification. It allows
you a much finer and detail control on what you need to load using a
standard API.

So maybe eclipselink implements entity graph using fetchgroup. But anyway it is not clear how to fix this problem.

The question moved to Gemini Jpa https://www.eclipse.org/forums/index.php/t/1078217/

[Updated on: Wed, 08 June 2016 15:43]

Report message to a moderator

Re: JPA: EntityGraph -> FetchGroupException [CLOSED] [message #1734847 is a reply to message #1734453] Mon, 13 June 2016 13:39 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1272
Registered: July 2009
Senior Member
You should fix your weaving issues first, as they are required to get entity graph functionality built into your Entities. The "eclipselink.weaving" property tells EclipseLink that an agent should be involved to weave the classes - you still need to either manually add the agent to your JVM, or be using a container that supports JPA weaving. See http://www.eclipse.org/eclipselink/documentation/2.5/concepts/app_dev007.htm
Re: JPA: EntityGraph -> FetchGroupException [CLOSED] [message #1734853 is a reply to message #1734847] Mon, 13 June 2016 13:55 Go to previous messageGo to next message
Pavel No is currently offline Pavel NoFriend
Messages: 45
Registered: May 2016
Member
I don't understand you. I use dynamic weaving. As I understand, in order to do it I must only write in persistence.xml

<property name="eclipselink.weaving" value="true"/>


If not, what else should I do? I use EclipseLink in JavaSE

P.S. I asked this question on SO - http://stackoverflow.com/questions/37746308/jpa-entitygraph-and-map

[Updated on: Mon, 13 June 2016 13:58]

Report message to a moderator

Re: JPA: EntityGraph -&gt; FetchGroupException [CLOSED] [message #1734884 is a reply to message #1734453] Mon, 13 June 2016 13:39 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1272
Registered: July 2009
Senior Member
You should fix your weaving issues first, as they are required to get entity graph functionality built into your Entities. The "eclipselink.weaving" property tells EclipseLink that an agent should be involved to weave the classes - you still need to either manually add the agent to your JVM, or be using a container that supports JPA weaving. See http://www.eclipse.org/eclipselink/documentation/2.5/concepts/app_dev007.htm
Re: JPA: EntityGraph -&gt; FetchGroupException [CLOSED] [message #1734891 is a reply to message #1734453] Mon, 13 June 2016 13:39 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1272
Registered: July 2009
Senior Member
You should fix your weaving issues first, as they are required to get entity graph functionality built into your Entities. The "eclipselink.weaving" property tells EclipseLink that an agent should be involved to weave the classes - you still need to either manually add the agent to your JVM, or be using a container that supports JPA weaving. See http://www.eclipse.org/eclipselink/documentation/2.5/concepts/app_dev007.htm
Re: JPA: EntityGraph -&gt; FetchGroupException [CLOSED] [message #1734976 is a reply to message #1734891] Tue, 14 June 2016 10:54 Go to previous messageGo to next message
Pavel No is currently offline Pavel NoFriend
Messages: 45
Registered: May 2016
Member
Forum seems to duplicate posts. So I ask you again - please, explain what else should I do to enable dynamic weaving besides <property name="eclipselink.weaving" value="true"/> in config.
Re: JPA: EntityGraph -&gt; FetchGroupException [CLOSED] [message #1735625 is a reply to message #1734976] Tue, 21 June 2016 13:23 Go to previous message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1272
Registered: July 2009
Senior Member
https://wiki.eclipse.org/EclipseLink/UserGuide/JPA/Advanced_JPA_Development/Performance/Weaving/Dynamic_Weaving
Previous Topic:Report security Issue
Next Topic:EclipseLink: weaving, inheritance - entities in different jar
Goto Forum:
  


Current Time: Tue Nov 21 02:56:02 GMT 2017

Powered by FUDForum. Page generated in 0.02770 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software