June 2018
Intermediate to advanced
408 pages
11h 23m
English
A dynamic entity graph is similar to a named entity graph, with the difference that we can define it dynamically through the Java API. The following is an example of how to define an entity graph using the Java API:
EntityGraph<?> entityGraph = getEntityManager().createEntityGraph(Account.class);entityGraph.addSubgraph("transactions");Map<String, Object> hints = new HashMap<String, Object>();hints.put("javax.persistence.fetchgraph", entityGraph);return this.getEntityManager().find(Account.class, accountId, hints);
So, if we have lots of use case-specific entity graphs, this approach will be an advantage over named entity graph where adding an annotation on our entity for each use case makes code unreadable. We can keep ...
Read now
Unlock full access