I’m building a REST service in java that does basic CRUD operations on Customers. The easy way would be for me to create one Customer model, and annotate it with JPA annotations so my persistence layer knows how to map it to the DB and add some jackson annotations so that my web layer knows how to deserialize it from http requests and serialize it into responses.
If I’m doing things the correct DDD way, should I have 3 versions of Customer?
- A Customer Domain object not polluted by annotations
- A CustomerDTO for the web layer with the jackson annotations
- A CustomerPersistence object with the JPA annotations
This seems like a lot of versions of the same thing, does anyone do things this way?