The scope of EntityGraph should be persistence unit, not persistence
context.
The method such as EntityManager.createEntityGraph(String name) etc. looks
non-intuitive. If an application wants to create a graph at runtime, it
should call EntityManagerFactory.createEntityGraph(String name).
As the API currently stands, it seems to allow EntityGraph of the same name
be defined by two separate persistence contexts -- opening up a pandora's
box of confusion. It is much safer to define these graphs scoped at
EntityManagerFactory level and imposing uniqueness on the name of the
graphs.
Regards --
Pinaki Poddar
Chair, Apache OpenJPA Project
http://openjpa.apache.org/
JPA Expert Group Member
Application & Integration Middleware