I write in java and try using DDD.
App schema (Interfaces is controllers, GUI etc.)
My question is:
How save data to database from aggregation root without getters. I would like have only >clean buissnes behavior. Maybe my aggregation root should create DTO object?(but is smell)
May be you are looking for ports-and-adapters architecture pattern.
Usual approach - place business and infrastratucture code in same package but in different modules
You even can make your AR non-public without public getters/setters.
Example:
https://github.com/ddd-by-examples/factory
look at
Examples of Domain Model in code: aggregate ProductDemand entity DailyDemand
in description - ProductDemand and DailyDemand not public, placed in demand-forecasting-model module at package io.dddbyexamples.factory.demand.forecasting
Now look at package io.dddbyexamples.factory.demand.forecasting in module demand-forecasting-adapters and you will see infrastructure implemmentation
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.