Skip to content
Sharp

Spring Core · interview question

Why is returning a JPA entity directly from a controller risky?

Multiple choiceHardchapter-9-curatedpremiumspring-coredtos-and-entities
Choose one answer
Answer and explanation

Correct answer

B. It couples the public API to internal persistence shape and can leak unwanted fields

Why

Entities often contain persistence concerns or sensitive fields that should not leak outward. DTOs give you a stable API contract that is decoupled from internal schema and ORM decisions.

Test yourself on Spring Core

A free test with instant, explained results. No account needed.

Start free test
All Spring Core questions →