Skip to content

Instantly share code, notes, and snippets.

@tkfx
Created June 22, 2016 09:44
Show Gist options
  • Select an option

  • Save tkfx/f98f17ed68b7c93392dfa303dddee818 to your computer and use it in GitHub Desktop.

Select an option

Save tkfx/f98f17ed68b7c93392dfa303dddee818 to your computer and use it in GitHub Desktop.
EntityManager em = emf.createEntityManager();
em.getTransaction().begin();
Author a = em.find(Author.class, 1L);
em.getTransaction().commit();
em.close();
log.info(a.getFirstName() + " " + a.getLastName() + " wrote "+a.getBooks().size() + " books.");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment