Codex Check Spring Data JPA List Queries for N+1 Reads
Use lazy loading, targeted fetches, or projections to control Spring Boot reads and verify both results and SQL.
中文Install in Codex
Use Spring Boot with Hibernate and a local test database. The exercise uses synthetic catalog items and categories.
- Copy the pinned `docs/zh-CN/skills/jpa-patterns/` directory into `.agents/skills/jpa-patterns/` in the project.
- Give Codex the entities, repository method, and display fields. Capture the current SQL and result set.
Example task
Create five fictional products and two categories. Display only product and category names. Compare current mapping with a DTO projection and inspect order and SQL.What to check
The projection preserves fields and order, and the SQL trace shows category data arrives without a separate query per product.
Original SKILL.md on GitHub · Updated
Frequently asked question
Should all associations become eager?
Choose loading strategies based on the read path, then verify SQL so changes do not increase loading on unrelated queries.