Spring Data JPA provides repository abstractions that hide SQL behind Java interfaces. It derives queries from method names or JPQL, making application logic concise but executed queries harder to inspect. section 6.3.2
When a framework hides a slow or unexpected query, profile the JDBC boundary rather than searching the repository interface. VisualVM can capture SQL before it reaches the DBMS, allowing investigation in a SQL client. section 6.3.2
A practical investigation checks:
- Which SQL statements does an endpoint actually send? section 6.3.2
- How often does each repository operation produce a query? section 6.3.2
- Can the captured statement be copied into a SQL client for performance analysis? section 6.3.2
A repository with hidden SQL
A ProductRepository extending JpaRepository<Product, Integer> contains no visible SQL. Profiling a products endpoint reveals two generated statements; Hibernate executes the second only once even when the repository method is called ten times. section 6.3.2
public interface ProductRepository
extends JpaRepository<Product, Integer> {
}
Inspect the minimal repository interface that delegates query generation and persistence behavior to the framework. section 6.3.2

