Dozer Mapping

RodneyEberly

Note from the editor:   This post was made on 08/31 but we did not see it pending until now.  The post is valid for the 08.2011 Great Tech Blog-Off Contest.

If anyone of you programs in Java, I suggest you check out Dozer. http://dozer.sourceforge.net/
It is a Java bean mapper that copies one Java bean’s data to another bean. We have been using it in production at work for over a year, and have been very pleased with it. We store our data in xml, and use Castor (another very useful tool) to create a Java bean representation of the xml, based off of a schema. However, our site has its own web beans, so we needed a way to map the data back and forth between the Castor beans and the web beans.

Dozer is a powerful tool for programming the mapping back and forth very quickly. We have been using the Dozer’s XML mapping. Basically you define the two objects to map between in your mapping xml file, and then define the desired field to field mapping. The mapping file is bidirectional, so you only have to define everything once.

There are many nice features available. If the field name (ie. first name) is the same in both the source bean and destination bean, you don’t even need to specify it. Dozer will automatically take care of it. If that specific mapping is not desired, you can always exclude. It is bi-directional by default, but you can also specify one-way mapping only, if needed. It will automatically map collections, arrays, primitives to primitives, Strings to primitives, and many more. You can specify field mappings that are multiple levels deep. If you need more elaborate mapping, (ie. manipulating data, calculations, etc.), you can always specify your own custom mapper (java class file).

So if you stuck through this article, followed it, and program (not drink) Java, check Dozer out!

By Guest Blogger December 9, 2025
Why Device Management Is Critical
November 4, 2025
Why Cybersecurity Hygiene Matters for SMBs
October 28, 2025
Why Leading with AI Matters for Small and Medium-Sized Businesses
October 10, 2025
Fake CAPTCHA Sites Hijack Clipboard to Install Malware
October 10, 2025
Understanding Business Email Compromise (BEC)
By Kordel Eberly August 17, 2025
Welcome to the Cyber Cold War
fish hook
By Eberly Systems September 20, 2024
We're all in the same boat trying to avoid cybercrime! Here's our top ways to identify a potential phishing attempt.
By Eberly Systems September 10, 2024
Focus on integrating with new team members and new customers
By Eberly Systems July 9, 2024
Keeping you abreast of security news