Spring数据JPA如何重用@NamedEntityGraph?

时间:2019-02-08 16:07:52

标签: hibernate spring-data-jpa

@NamedEntityGraphs({
        @NamedEntityGraph(name = CITY_BASIC, attributeNodes = {
                @NamedAttributeNode("state"),
                @NamedAttributeNode("country")
        }),
        @NamedEntityGraph(name = CITY_DETAILS, attributeNodes = {
                @NamedAttributeNode("state"),
                @NamedAttributeNode("country"),
                @NamedAttributeNode(value = "suburbs", subgraph = "basic")
        },
                subgraphs = @NamedSubgraph(name = CITY_BASIC, attributeNodes = {
                        @NamedAttributeNode("state"),
                        @NamedAttributeNode("country")
                }))
})
public class City {
  private String name;
  private State state;
  private Set<City> suburbs;
}

另一个具有City对象的类,例如

public class Address {
  private String street;
  private City city;
}

如果我希望Address的实体图使用子图中的现有CITY_BASICCITY_DETAILS实体图,该怎么办?

0 个答案:

没有答案