JPA: EntityGraph -> FetchGroupException when Entity is in another bundle [message #1734478] |
Wed, 08 June 2016 15:42 |
Pavel No Messages: 47 Registered: May 2016 |
Member |
|
|
I use EclipseLink 2.6.3 as a JPA provider and OSGi.
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.
However, I found out that this problem occurs only when Entity is in another bundle. If it is in the same bundle where persistence.xml file is located everything is ok. How to fix it?
This is stack
at org.eclipse.persistence.exceptions.QueryException.fetchGroupValidOnlyIfFetchGroupManagerInDescriptor(QueryException.java:1305)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.prepareFetchGroup(ObjectLevelReadQuery.java:2079)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.prePrepare(ObjectLevelReadQuery.java:2099)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.checkPrePrepare(ObjectLevelReadQuery.java:928)
at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:822)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1134)
at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:460)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:1222)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2896)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1857)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1839)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1804)
at org.eclipse.persistence.internal.jpa.QueryImpl.executeReadQuery(QueryImpl.java:258)
at org.eclipse.persistence.internal.jpa.QueryImpl.getResultList(QueryImpl.java:473)
[Updated on: Wed, 08 June 2016 15:47] Report message to a moderator
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03292 seconds