r/SpringBoot • u/Snoo23482 • Jun 18 '26
Question Dto Mapping Best Practice
Hi, where do you guys map your entities to dtos?
In services or controllers?
To me it seems the services shouldn't expose any database specifics to the outside world, so I usually do my mapping there.
But what is considered best practice and why?
52
Upvotes
View all comments
Show parent comment
1
u/Snoo23482 Jun 18 '26
It's all good if you are using records to communicate to the outside word.
But if it is another additional kind of endpoint, say grpc, then you suddenly need to either map twice or add another service method taking the grpc dto.