Use DAO in Java as a persistence boundary when explicit query and storage control matter more than exposing ORM or repository details directly.
DAO remains useful in Java, but not as a mandatory layer around every persistence framework. In modern codebases it is strongest when it makes database access clearer, isolates query logic, or shields the rest of the system from storage-specific concerns.
This section treats DAO as a persistence-boundary pattern. The important questions are what the boundary owns, how much of the ORM or query model leaks through it, and when a dedicated DAO is clearer than a raw repository, entity manager, or framework-generated interface.