persistence icon indicating copy to clipboard operation
persistence copied to clipboard

make it easier to obtain EntityGraphs

Open gavinking opened this issue 1 year ago • 0 comments

Currently operations for obtaining an EntityGraph are distributed apparently at random between EntityManager and EntityManagerFactory. By rights they belong on EntityManagerFactory, but I suppose people wanted to economize on a call to getEntityManagerFactory() for typical usage patterns. Now EntityAgent is also in the picture.

I have two proposals:

  1. Create a GraphFactory/Registry/Manager interface—or whatever you prefer to call it—as a supertype of EntityManager, EntityAgent, and EntityManagerFactory and pull up all the operations to this supertype.
  2. Add a createGraph() method to EntityType, making it possible to write Book_.class_.createGraph().

Note that these enhancements should be completely trivial to implement for any existing JPA provider.

gavinking avatar Jan 08 '25 14:01 gavinking