Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 360
Benjamin Avatar asked Feb 19 '26 11:02

Benjamin


1 Answers

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.

like image 118
Vinod R Avatar answered Feb 20 '26 23:02

Vinod R



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!