@Test public void test() { doInJPA( entityManager -> { Post post = new Post(); post.setId(1L); post.setTitle("High-Performance Java Persistence"); entityManager.persist(post); }); doInJPA( entityManager -> { Post post = entityManager.find(Post.class, 1L); LOGGER.info("Fetched post: {}", post); post.setScore(12); }); }