I've recently discovered Named Entity Graphs, and I'm trying to implement them in a clean, DRY way.
What I'm not sure about (and reading through the JPA and Spring Data Docs hasn't answered) is the scope of the names used. Are the private to the classes they're defined in, or can I do something like this:
@Entity
@NamedEntityGraphs({
@NamedEntityGraph(name = "Route.deep",
attributeNodes = {
@NamedAttributeNode(value = "stops", subgraph = "Stop.deep ")
})
})
public class Route { ... }
@Entity
@NamedEntityGraphs({
@NamedEntityGraph(name = "Stop.deep",
attributeNodes = {
@NamedAttributeNode(value = "records")
})
})
public class Stop{ ... }
Where the Stop.deep subgraph in Route refers to the named entity graph in Stop.
Thanks!