Cosium / spring-data-jpa-entity-graph

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

Add optinal DynamicEntityGraph configuration mode #187

Closed anibalanto closed 1 month ago

anibalanto commented 1 month ago

Hello, I want simplify DynamicEntityGraph configuration. One option today is:

    Product product =
        productRepository
            .findById(
                1L,
                ProductEntityGraph.____()
                    .brand()
                    .____
                    .category()
                    .____
                    .maker()
                    .country()
                    .____
                    .____())
            .orElseThrow(RuntimeException::new);

  }

I add an option to do the same:

    Product product =
        productRepository
            .findById(
                1L,
                ProductEntityGraph.inic_(
                    productEG ->
                        productEG
                            .brand_()
                            .category_()
                            .maker_(makerEG -> 
                                makerEG
                                    .country_())))
            .orElseThrow(RuntimeException::new);
reda-alaoui commented 1 month ago

@anibalanto I don't understand the expected gains with this PR. Could you give more details?

anibalanto commented 1 month ago

Hello @reda-alaoui ! I update my first description.

Thank!

reda-alaoui commented 1 month ago

@anibalanto , I don’t find the added option more readable. IMO, adding it to the project will lead to cluttered code in consuming projects.

If you want/need an extension point to plug a custom EG style defined outside of this project, I’d welcome it. But maybe you should just create a full annotation processor on your side without using the one defined here.