Java Reference
In-Depth Information
System.out.println("students Was loaded ?
Dynamic entity graphs
Entity graphs can also be defined at runtime. To do this, we must use the cre-
ateEntityGraph() method of the entity manager and not getEntityGraph()
as with the named entity graphs. Once defined, the dynamic entity graph is asso-
ciated with the find() method or a query in the same way as a named entity graph
as shown in the following code.
The following code is an example of using a dynamic entity graph:
EntityManager em = emf.createEntityManager();
//create entity manager
PersistenceUnitUtil pUtil =
Department depart = (Department)
em.createQuery("Select e from Department e")
System.out.println("students Was loaded ? " +
pUtil.isLoaded(depart, "students"));
EntityGraph includeThis =
depart = (Department) em.createQuery("Select e
from Department e")
System.out.println("students Was loaded ? "
+pUtil.isLoaded(depart, "students"));
Search WWH ::

Custom Search