Search code examples
javahibernatedozer

Dozer Mapping and Hibernate lazy initialization


i have the following dozer mapping:

com.company.xx.xx.model.MyClass com.company.xx.xx.model.MyClassToMap

afield afield

customer customer

I load MyClass with with hibernate. But i have a lazy loading for customer. i dont load everything from customer. But the mapping wants to map all attributes from customer, so that a lazy initilization exception is thrown.

How can i tell dozer only to map customer and not all of the fields from customer?


Solution

  • You will need to write a custom converter to assign null to uninitialized collections. When you implement the custom converter make use of Hibernate.isInitialized check and set collections to null where it is not necessary.

    The link http://dozer.sourceforge.net/documentation/customconverter.html gives an idea about custom converters.