I use Hibernate3-based JPA and use staeless session beans for DAOs. Suppose that I have 2 tables: Category and Item (i.e. 1 category has many items and 1 item can belong to many categories).
Until now I saw 2 ways to avoid lazy initialization exception:
- @ManyToMany(fetch=FetchType.EAGER)
- using FETCH JOIN: a guy in this company even wrote a bunch of classes to help build the JQL with fetch join programmatically (it works but complicated and clumsy, IMHO).
Any solution as good as Spring's OpenEntityManagerInViewFilter (for web apps) and ... well, I don't know how Spring solves this problem for desktop apps.
|