Cosium / spring-data-jpa-entity-graph

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

EntityGraphJpaRepository.findAllById(...) still returns Iterable instead of List #201

Closed fladdimir closed 2 months ago

fladdimir commented 4 months ago

First of all, thanks a lot for your great work on this awesome project.

Just a minor issue: standard find[...] methods of the EntityGraphJpaRepository do return Iterable results, different to their (more convenient) non-entity-graph-counterparts of the JpaRepository which now return List instead.

Spring-Data started to offer List return-types some time ago with their List[...]Repository interfaces, e.g. ListCrudRepository ( https://spring.io/blog/2022/02/22/announcing-listcrudrepository-friends-for-spring-data-3-0 ).

What steps will reproduce the problem ?


    public interface BrandRepository extends EntityGraphJpaRepository<Brand, Long> {}

    // [...]

    // nice List return type:
    List<Brand> brandsWithoutEntityGraph = brandRepository.findAllById(List.of(1L));
    // less convenient Iterable return type when providing an entity-graph:
    Iterable<Brand> brandsWithEntityGraph = brandRepository.findAllById(List.of(1L), BrandEntityGraph.____().products().____.____());

https://github.com/fladdimir/spring-data-jpa-entity-graph/blob/09c44d46126264f6aa951fa13f988e630ade0259/core/src/test/java/com/cosium/spring/data/jpa/entity/graph/repository/EntityGraphJpaRepositoryTest.java#L345

What is the expected output ?

It could be more convenient if standard EntityGraphRepository methods would return List instead of Iterable?

fladdimir commented 4 months ago

possible solution: https://github.com/Cosium/spring-data-jpa-entity-graph/pull/202

as part of that (breaking) change, the spring-data-jpa-entity-graph interface-hierarchy could be updated to again mirror the changed interface-hierarchy of spring-data-jpa ?

old spring-data-jpa interface-hierarchy: spring_data_past

current spring-data-jpa interface-hierarchy: spring_data_present

current spring-data-jpa-entity-graph interface-hierarchy: sdjpa_eg_present

proposed future spring-data-jpa-entity-graph interface-hierarchy: sdjpa_eg_future