I have a problem that I'm struggling to solve. The problem ist that I want to migrate an existing application into an appliction with a proper domain layer.
The existing application really is just big collection of database queries because all business logic is implemented inside the database with triggers, procedures and functions. All the application does is query some data, manipulate the data in an anemic domain model and store the result back to the database so the database can apply the business logic, validate, etc.
The business logic inside the database really is just to intertwined with everything else to really pull it apart bit by bit.
The only solution I came up with until now is to connect the a completely new domain layer with the existing data access layer with an appropriate adapter. Mainly in the form of domain model <-> database entity converters. But if I do that I can't just use the domain logic of my domain model and store the end results back to the database, because it would violate the implemented business logic and validations inside the database. So any complex transaction must still store back it's intermediate results to the database, hence I'm still stuck with an anemic domain model.
Has somebody got an idea how to tackle this situation and gradually migrate towards a rich domain model?
I had the same problem and I got this solution. I hope this proves useful.