Skip to content

Instantly share code, notes, and snippets.

@thjanssen
Last active June 7, 2016 16:12
Show Gist options
  • Save thjanssen/d06f1a429b033779ee71e18991fc43a8 to your computer and use it in GitHub Desktop.
Save thjanssen/d06f1a429b033779ee71e18991fc43a8 to your computer and use it in GitHub Desktop.
em.createNamedQuery(“selectAuthors”).getResultList();
EntityGraph<?> graph = em.getEntityGraph(“graph.AuthorBooks”);
HashMap<String, Object> properties = new HashMap<>();
properties.put(“javax.persistence.fetchgraph”, graph);
em.find(Author.class, 1L, properties);
@NamedQuery(name = “selectAuthors”, query = “SELECT a FROM Author a”,
hints = @QueryHint(name = QueryHints.COMMENT, value = “a custom SQL comment”))
EntityGraph<?> graph = em.getEntityGraph(“graph.AuthorBooks”);
em.createQuery(“SELECT a FROM Author a”)
.setHint(“javax.persistence.fetchgraph”, graph)
.getResultList();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment