JPA Entity Graph: subgraph of a nested property

Viewed 438

we are importing a pre-existing project into sts , and we have many classes linked together, which unfortunately we cannot change. In an attemp to ease the server response we are triyng to implement @EntityGraph, but we encounter a road block. having this classes :

public class Country:

    @OneToMany
    @Fetch(FetchMode.JOIN)
    @JoinColumn(name = "countryId", referencedColumnName = "ID")
    private Set<CountryModel> modelList;


public final class CountryModel {
    @EmbeddedId
    private CountryModelId id;
.....
}

@Embeddable
public class CountryModelId {
..
    @ManyToOne
    @JoinColumn(name="VET", nullable=false)
    private Model model;
....}

public class Model{

    @OneToMany(mappedBy = "id.vetele")
    @Fetch( FetchMode.JOIN)
    private Set<ModelTechdata> techdataList;

... }

is it possibile for me to create a subgraph for techdataList inside the Country class ? i.e. something like this:

@Entity
@NamedEntityGraph(name = "Country.entitiesGraph", attributeNodes = {
        @NamedAttributeNode(value = "modelList", subgraph = "Country.entitiesGraph.techdataMap"),
        @NamedAttributeNode(value = "countryCallToAction") }, subgraphs = {
                @NamedSubgraph(name = "Country.entitiesGraph.techdataMap", type = ModelTechdata.class, attributeNodes = {
                        @NamedAttributeNode(value = "id.model.techdataList") }) })
public class Country {
...}

thanks

0 Answers
Related