JPA: EntityGraph -> FetchGroupException [CLOSED] [message #1734453] |
Wed, 08 June 2016 13:21 |
Pavel No Messages: 47 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
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03338 seconds