Reputation: 125
I've been facing the LazyInitializationException and had three solutions by googling it:
i'm avoiding the eager fetching and was wondering what's the difference between eager fetching and join fetch. could anyone tell me what's the best solution?
Upvotes: 3
Views: 489
Reputation: 128829
The best solution is likely one that you didn't list: the open session in view pattern. Spring provides a very convenient implementation of the pattern in the form of either a Servlet Filter or a method interceptor.
Eager fetching describes the laziness of a relationship, or when fetching happens. Join fetching describes the fetch strategy, or how fetching happens. The two are separate concepts. Section 21.1 of the Hibernate Reference Guide has a full description of the how and when bit along with a lot of other useful tidbits.
Upvotes: 2