Search code examples
jpaspring-data-jpaeclipselink

Two EntityGraph on same class is not working (EclipseLink)


Iam trying to add a second EntityGraph on my class.

 @NamedEntityGraph( name = "foo.details", attributeNodes = {
                    @NamedAttributeNode("id" ),
                    @NamedAttributeNode( "bar" )})

     
 @NamedEntityGraph( name = "foo.without.details",
                     attributeNodes = { @NamedAttributeNode( "id" ) } )
public class Foo{

The repository

 @Override    
 @EntityGraph( value = "foo.without.details" )   
 Page<Foo> findAll(Predicate predicate, Pageable pageable );

If i use the second entityGraph is get follow error

Caused by: javax.persistence.PersistenceException: Exception [EclipseLink-6114] (Eclipse Persistence Services - 2.7.8.v20201217-ecdf3c32c4): org.eclipse.persistence.exceptions.QueryException │
│ Exception Description: You must define a fetch group manager at descriptor (Foo) in order to set a fetch group on the query (null) │
│ Query: ReadAllQuery(referenceClass=Aspect sql="SELECT id FROM foo WHERE (description LIKE ? ESCAPE ? AND (tenant_id = ?)) ORDER BY id ASC") │
│ FetchGroup(foo.without.details){} │
│ at org.eclipse.persistence.internal.jpa.QueryImpl.getResultList(QueryImpl.java:493) │
│ at com.querydsl.jpa.impl.AbstractJPAQuery.getResultList(AbstractJPAQuery.java:160)

What I also tried, is to use the wrapper annotation'NamedEntityGraphs' and to annotate the spring data repository.

   @Override
   @EntityGraph( attributePaths = "id" )
   Page<Foo> findAll( Predicate predicate, Pageable pageable );

Without the second EntityGraph all works:

Static weaving with Maven is enabled and logging is enabled

Anybody an idea what is wrong?

EDIT: weving Info

[INFO] --- eclipselink-maven-plugin:2.7.5.1:weave (default) @ 
[INFO] Only entities from base packages 'foo' will be included in persistence.xml 
[INFO] Entities found : 12 
[INFO] persistence.xml location: [INFO] Eclipselink weaving completed

Class file

public class Foo implements PersistenceWeaved,PersistenceObject, PersistenceWeavedFetchGroups, PersistenceWeavedLazy, PersistenceWeavedChangeTracking

Solution

  • The issue is the maven version. Upgrade to a new maven version and all works fine!