我在我的应用程序中使用 @NamedEntityGraph
@NamedEntityGraphs({
@NamedEntityGraph(name = "graph.Employee.assignments", attributeNodes = @NamedAttributeNode("assignmentProjectEmployeeSet")),
@NamedEntityGraph(name = "graph.Employee.absences", attributeNodes = @NamedAttributeNode("absences"))
})enter code here`public class Employee {
当我在存储库中使用它时
@EntityGraph(value = "graph.Employee.assignments", type = EntityGraph.EntityGraphType.FETCH)
List<Employee> findAll();
我得到了预期的所有结果。但是对于不同的情况,我需要几个版本的 findAll() 。就像是
@EntityGraph(value = "graph.Employee.assignments", type = EntityGraph.EntityGraphType.FETCH)
List<Employee> findAllWithAssignments();
@EntityGraph(value = "graph.Employee.absences", type = EntityGraph.EntityGraphType.FETCH)
List<Employee> findAllWithAbsences();
但是如果我尝试在存储库中定义一个新的方法名称,我会收到一个应用程序上下文错误,因为 Spring 无法解析 mehtod 名称。
有没有可能得到这样的方法?
谢谢
马蒂亚斯