LazyInitializationException « EntityManager « JPA Q&A





1. Why does EntityManager.merge() prevent LazyInitializationException while EntityManager.find() don't?    stackoverflow.com

Given the following situation in a web application:

// EntityManager em, one per Request with Spring's OpenEntityManagerInViewFilter
// Parent oldParent, from previous request (and therefore another persistence context)
Parent parent = em.find(Parent.class, oldParent.getId());
List<Child> children ...