Skip to content

Spring Data JPA extension allowing full dynamic usage of EntityGraph on repositories

License

Notifications You must be signed in to change notification settings

deyaeddin/spring-data-jpa-entity-graph

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gitter Travis branch Codecov branch Maven Central 1.10.x Maven Central 1.11.x Maven Central Latest

Spring Data JPA EntityGraph

Life without spring-data-jpa-entity-graph

Spring Data JPA only supports EntityGraph through annotations.
Thus, for a repository method, you must select at most one EntityGraph before compilation.
This prevents you from choosing the best EntityGraph considering the runtime context 💔

Life with spring-data-jpa-entity-graph

Thanks to spring-data-jpa-entity-graph, you can choose EntityGraph at runtime!
This choice is elegantly made by passing EntityGraph, as an argument, to any Spring Data JPA repository method 😍

Example:

// This will apply 'Product.brand' named EntityGraph to findByLabel
productRepository.findByLabel("foo", EntityGraphs.named("Product.brand"));

// This will apply 'Product.supplier' named EntityGraph to findByLabel
productRepository.findByLabel("foo", EntityGraphs.named("Product.supplier"));

Now run to the documentation !

Documentation

This library follows the Spring Data JPA versionning semantic.

spring-data-jpa branches Latest spring-data-jpa-entity-graph version Documentation
2.0.x Maven Central Latest 2.0.x documentation
1.11.x Maven Central 1.11.x 1.11.x documentation
1.10.x Maven Central 1.10.x 1.10.x documentation

Example: if you were using spring-data-jpa 1.10.13 in your project, you would need to select any spring-data-jpa-entity-graph 1.10.x. Thus spring-data-jpa-entity-graph 1.10.14 would be eligible.

Talk

Slides of the talk Making JPA Great Again given at Paris JUG in January 2019 are available at https://cosium.github.io/making-jpa-great-again/

Genesis

This project was created following the discussion in Spring Data Tracker issue DATAJPA-749 - Context enabled JPA 2.1 @EntityGraph .

About

Spring Data JPA extension allowing full dynamic usage of EntityGraph on repositories

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 99.9%
  • Shell 0.1%