I am using Dozer to map from one to second object, but Iam geting error:
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: ... , could not initialize proxy - no Session
When I use before mapping field.size() for all collections it works, but its really annoying. Is there some option to load hibernate object with initialized all collections eagrly?|
This is not dozer's problem. You are accessing yor data in a wrong way. In your hibernate entity, you have some lazy reference (to collection, another entity,...), but you are converting it to some bean outside hibernate session (your entity is in so called 'detached' state).
Solution for this problem depends on your situation. You can:
The mapped field size
may work even with lazy collections. The number of elements may be known, but the content not.
EDIT: more solutions: