Lots of beans duplication

Hi all,

From auction/address book example I notice several beans that share

many identical properties, among them are:

1. Command objects.
2. Beans used by JPA to persist to query database.
3. DTOs returned by query side.

For ease of maintenance, what's the best practice to deal with those
beans ?

Thanks & Regards,


What I try to do in most cases, is to find concepts in the domain that combine several properties. Then I create value objects that represent these properties. The result is that only a single object (A value object) is passed around.

A very typical example is “address”. Instead of passing around “street”, “housenumber”, etc, there is only a single object.



Hi Allard,

Yes, your solution is going to help to some extent.

But some entities have lots of properties by nature, for instance a
Customer entity in CRM system & maintaining those properties & their
commands, DTOs, JPA classes etc are no fun, moreover for some command
(update, approve, etc) you only need just a few of them.

Thanks & Regards,


Define your classes (Commands, Events, DTOs etc) in a simple DSL and
use code generation to take care of them.


Thank you for you suggestion.

What DSL tool/framework do you recommend for this task ?

For now, I'm using project Lombok.