微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

同一类上的两个 EntityGraph 不起作用EclipseLink

如何解决同一类上的两个 EntityGraph 不起作用EclipseLink

我正在尝试在我的班级中添加第二个 EntityGraph。

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

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

仓库

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

如果我使用第二个 entityGraph,则会出现跟随错误

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)

我还尝试过,使用包装器注释“NamedEntityGraphs”并注释 spring 数据存储库。

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

没有第二个 EntityGraph 一切正常:

使用 Maven 启用静态编织并启用日志记录

有人知道出了什么问题吗?

编辑:编织信息

[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

文件

public class Foo implements Persistenceweaved,PersistenceObject,PersistenceweavedFetchGroups,PersistenceweavedLazy,PersistenceweavedChangeTracking

解决方法

问题是maven版本。升级到新的 maven 版本,一切正常!

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。