以下是我的课程:
主要项目:
@Data
@MappedSuperclass
public abstract class ProjectMain<S> extends ProjectBase {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "ProjectId")
private Long projectId;
@OneToMany(mappedBy = "project", orphanRemoval = true)
private Set<ProjectReaction> reactions;
@OneToMany(mappedBy = "project", orphanRemoval = true, fetch = FetchType.EAGER)
private List<S> projectDuplicates;
}
项目:
@NamedEntityGraph(
name = "project-entity-graph",
attributeNodes = {
@NamedAttributeNode("projectDuplicates"),
@NamedAttributeNode("portal"),
@NamedAttributeNode("reactions")
})
@Data
@Entity
@Table(name = "Projects")
public class Project extends ProjectMain<ProjectDuplicate> {}
存储库:
@NoRepositoryBean
public interface ProjectBaseRepository<T extends ProjectMain<S>, S extends ProjectDuplicateMain<T>> extends JpaRepository<T, Long>,
JpaSpecificationExecutor<Project> {
@EntityGraph(value = "project-entity-graph" , type= EntityGraph.EntityGraphType.FETCH)
List<T> findSimilarProjects(...)
}
如果我在project.class中创建entitygraph,一切正常。但是,当我想创建10个继承自抽象类projectmain的类时,有一个问题。是否可以为从projectmain继承的所有类和存储库中的一个方法创建一个实体图?
暂无答案!
目前还没有任何答案,快来回答吧!