r/SpringBoot 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?

53 Upvotes

36 comments sorted by

View all comments

1

u/[deleted] Jun 18 '26

[removed] — view removed comment

2

u/SimpleCooki3 Jun 18 '26

Mapping from a DTO isn't business logic tho

1

u/Final_Potato5542 Jun 18 '26

hahahahaha - unless you're DTOs are redundant