Closed VladyslavLevchuk closed 4 years ago
It seems you didn’t understand entitygraph purpose. This is not a place for questions about the JPA specification or Hibernate. Your question is suited for stackoverflow.
@reda-alaoui But why? There isn't any example with subgraphs using this lib in your docs. I can see only this simple one EntityGraphUtils.fromAttributePaths("brand", "maker"). But what about subgraph capability? This is strictly directed to this lib and I thought that it is kind of a bug to fetch all table fields even though I specify only the needed one for fromAttributePaths(...). I think this would be helpfull for others too...
https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#projections.interfaces Vlad is projections not enough for you ?
@ylcinyakup Nope, because I am going to use graphql, that's why I don't have predefined API's with predefined amount of fields and objects. For this matter I am going to use dynamic entity graph capability of this lib.
There is Department entity that has field LocationEntity as @ManyToOne. LocationEntity entity has several fields streetAddress, postalCode, city etc... If I specify EntityGraphUtils.fromAttributePaths(new String[] {"department.location", "department.location.streetAddress"}) I can see that Hibernate fetches all fields from location table even though I specified only streetAddress field. I've been wondering if there is any capability such as @NamedSubgraph to able to specify only the needed fields to be fetched from child entity?