I have the following situation in my spring boot application:
I use unidirectional relationship modelling for my database entities, in order to prevent difficulties with a bidirectional approach. (Cascading, Updating both sides etc.) Of course I don't want to expose this structure to the presentation layer, thus my DTOs are compositions over multiple tables. Now I have the following question: How do I properly aggregate this DTOs?
At the moment I have a datacomposition service, which calls the relevant services and builds the DTOs. This service is transactional, because otherwise I could create something in one service, but won't be able to roll it back if something goes wrong in antother one. This is cleanest approach I came up with. Before my controller did this work, but this was a bad idea because of the transaction handling. My Problem with this approach is that this datacomposition service returns DTOs, which I don't like since I belong to the group saying, that the service layer only deals with domain objects. Is this acceptable?
Thank you for your help!
the service layer only deals with domain objects.
Why?DDD
has an element named service with a particular scope and goal, but this is not incompatible with having more services, at different layers (app layer for example) doing the mapping you need. There's no such a thing as a unique service layer. That's something springbooters developers fail to understand.