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

Deprecate default EntityGraph concept #73

Closed reda-alaoui closed 1 year ago

reda-alaoui commented 1 year ago

Now that #36 is fixed, the default EntityGraph concept should be deprecated for removal.

Some history

default EntityGraph concept has been introduced in 2016 at the start of the project. It was already duplicating the real default EntityGraph which is defined by JPA annotations.

For example:

public class Product {
  @ManyToOne(fetch = FetchType.LAZY)
  private Brand brand;
  @ManyToOne(fetch = FetchType.EAGER)
  private Manufacturer manufacturer;
}

In this example, the real default EntityGraph is (manufacturer) because brand is marked LAZY and manufacturer is marked EAGER.

So why the hell did we duplicate an already existing and JPA standardized concept?

Let's stay on the previous example. According to JPA, if I apply an empty EntityGraph:

Back then, ORM like hibernate were only supporting one kind of EntityGraph, the LOAD graphs. So no EntityGraph could ever remove a node from the real default EntityGraph !

Adding default EntityGraph concept allowed to workaround the lack of support for FETCH graphs.

Today

Today, JPA ORM support EntityGraph FETCH types. This is why, default EntityGraph concept should be removed from this library.