Java Bean Mapping with MapStruct

MapStruct is a nice tool to generate mappers for converting one Java bean into another e.g. for projections, data-transfer-objects and so on …​ As long as fields in source and target beans do match, the mapper is able to generate the data setting automatically .. else we may specify which source fields to map into which target fields or to register custom converters with ease. Using Maven, we need to add dependencies and plugin integration to our pom.xml: ...

March 31, 2022 · 3 min · 459 words · Micha Kops

XMLBeam: Snippets and Examples

XMLBeam is an interesting library using an approach of projecting parts of an XML DOM tree into Java using some simple interfaces, annotations and XPath expressions. In the following article, I’d like to share three experiments of mine with this library for reading, writing XML and parsing a live RSS feed. RSS Feed Projection Interface Dependencies Using Maven, we need to add only one dependency to our pom.xml: ...

July 22, 2014 · 6 min · 1126 words · Micha Kops

Creating slim Database Projections using JPA2 Constructor Expressions

One common question that you may encounter one day when using object-relational-mapping in your application is how to slim down data that you’re retrieving from the persistence layer down to a specific subset for your use-case in an efficient manner and without using complex additional mapping frameworks. In some situations you might declare lazy loaded fields but another approach that I’d like to share with you here are JPA2 constructor expressions. ...

April 14, 2013 · 9 min · 1744 words · Micha Kops