Hibernate / JPA Lazy Loading Pitfalls
Hibernate provides different kinds of relationships between entities like OneToMany, ManyToOne, ManyToMany or OneToOne. In the early days of Hibernate the fething strategy of all relationships was “lazy”. This stayed true for a long time and changed when Hibernate started to support JPA, because the JPA specification defines different default fetching strategies. The default fetching strategy up to Hibernate version 4.3 is: By default, Hibernate uses lazy select fetching for collections and lazy proxy fetching for single-valued associations. These defaults make sense for most associations in the majority of applications. Hibernate 4.3 manual, 20.1.1. Working with lazy associations In contrast to this the JPA specification specifies different default fetching strategies per… Read More »Hibernate / JPA Lazy Loading Pitfalls