Cosium / spring-data-jpa-entity-graph

Spring Data JPA extension allowing full dynamic usage of EntityGraph on repositories
MIT License
466 stars 51 forks source link

Cannot find @NamedSubgraph Capability #42

Closed VladyslavLevchuk closed 4 years ago

VladyslavLevchuk commented 4 years ago

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?

reda-alaoui commented 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.

VladyslavLevchuk commented 4 years ago

@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...

reda-alaoui commented 4 years ago

https://github.com/Cosium/spring-data-jpa-entity-graph/issues/24

ylcinyakup commented 4 years ago

https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#projections.interfaces Vlad is projections not enough for you ?

VladyslavLevchuk commented 4 years ago

@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.