persistence
persistence copied to clipboard
make it easier to obtain EntityGraphs
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:
- Create a
GraphFactory/Registry/Managerinterface—or whatever you prefer to call it—as a supertype ofEntityManager,EntityAgent, andEntityManagerFactoryand pull up all the operations to this supertype. - Add a
createGraph()method toEntityType, making it possible to writeBook_.class_.createGraph().
Note that these enhancements should be completely trivial to implement for any existing JPA provider.