Binder and embedded (JPA) valueobjects

I have and entity, which consists of some “flat” fields (i.e. Strings, Integers etc.) and some embedded (in JPA meaning, i.e. Address) as well. My question is, what is the best way to bind those fields to Vaadin components (i.e. TextField).
Two possible scenarios i’ve come up to are:

  1. Make getters/setters in parent object (“clean” bind with method referrence, but somehow redundant methods)
  2. Make separate binder for embedded object, and aggregate them in the end.

Both seem a little bit skewed to me, so I am asking you guys (and girls)

Third option: make a DTO object that contains all of the necessary information (including id) at root level and nothing else. This has proven to be a good way of dealing with JPA entities in many cases.

Fourth option: make a Proxy class that contains a reference to the original Entity and have getters and setters for all the required root or nested properties there.

My personal recommendation would be the DTO.

Was hoping there is a neat way to do this directly in binder (such like converting values), but the DTO solution actually suits me equally well. Thanks for reply!

Good to hear! I know there’s some boilerplate code that comes from creating DTOs, but luckily IDEs will help you with that.

-Olli