i use to get lazy initialization exception because of parentId for resolving that issue i used @Fetch(FetchMode.JOIN) on all the elements which are in relation with this class.
Now my exception is gone But i am wondering Is this wrong solution like Making "FetchType.EAGER" instead of LAZY and making < bean ...... lazy-init="false">........</bean> which throws away LAZY loading of objects.
@ManyToOne(fetch = FetchType.LAZY)
at the same time throw away LAZY loading feature of hibernate ?
See this is what the document says about join = fetch
With fetch="join" on a collection or single-valued association mapping, you will actually avoid the second SELECT (hence making the association or collection non-lazy), by using just one "bigger" outer (for nullable many-to-one foreign keys and collections) or inner (for not-null many-to-one foreign keys) join SELECT to get both the owning entity and the referenced entity or collection. If you use fetch="join" for more than one collection role for a particular entity instance (in "parallel"), you create a Cartesian product (also called cross join) and two (lazy or non-lazy) SELECT would probably be faster.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com