HS Ventures / Build log / Reel 11
Your API is leaking database fields
A Spring Boot tip: return a DTO, not the entity, for hidden internals and a stable API.
· 27 s
Your API is leaking database fields.
Return a DTO, not the entity: hidden internals and a stable API.
Follow for daily dev tips.
Transcript
If your controller returns an entity your API leaks database fields like password hashes and internal notes and every schema change breaks your clients. The fix is a DTO. Map the entity to a DTO and return that. You hide internal fields keep the API stable and avoid lazy loading errors. Entity mapper DTO client. Follow for daily dev tips.