Cosium / spring-data-jpa-entity-graph

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

Ad-hoc attribute paths #3

Closed goulashify closed 7 years ago

goulashify commented 7 years ago

Hey Guys and Gals!

So i've ran into the same problem as you did with Spring Data JPA as you did, i'm super happy that you made this plugin to solve it, huge-huge kudos, it already made my life easier!

I was thinking, Spring has ad-hoc entity graphs (see example 60th):

@Repository
public interface GroupRepository extends CrudRepository<GroupInfo, String> {

  @EntityGraph(attributePaths = { "members" })
  GroupInfo getByGroupName(String name);

}

Would it be convenient to do this:

final ProductRepository repo;
repo.findAll(EntityGraphUtils.fromAttributePaths("brand", "maker"));

?

I would be happy to research and make a pr about this if you think it would be helpful as well, let me know what do you think. :)

Have a pancake flavoured day, -Dan

reda-alaoui commented 7 years ago

Hello Dan,

Thanks for the kind words :)

Yeah, I think it would be a great EntityGraph helper method ! I suppose that the method would return an instance of DynamicEntityGraph.

https://github.com/Cosium/spring-data-jpa-entity-graph/blob/master/src/main/java/com/cosium/spring/data/jpa/entity/graph/domain/DynamicEntityGraph.java

Feel free to open a PR ;)

goulashify commented 7 years ago

Hi Réda!

Thanks for the fast response, i'll get to it in the evenings, hoping to make a PR in the coming days.

reda-alaoui commented 7 years ago

This will be available in release 1.10.14. The release has been performed and will be available in the next hour.

goulashify commented 7 years ago

Woohooo! Thx @reda-alaoui!