walterfan/lazy-ai-primer/jpa-patterns
- community
Checking that the SKILL.md file is still in the repository.
JPA/Hibernate patterns for entity design, relationships, query optimization, transactions, auditing, indexing, pagination, and pooling in Spring Boot.
Install
npx vskill@latest install walterfan/lazy-ai-primer/jpa-patternsSKILL.md
The same SKILL.md was published earlier as jamkris/everything-gemini-code/jpa-patterns.
JPA/Hibernate Patterns
Use for data modeling, repositories, and performance tuning in Spring Boot.
Entity Design
Enable auditing:
Relationships and N+1 Prevention
- Default to lazy loading; use
JOIN FETCHin queries when needed - Avoid
EAGERon collections; use DTO projections for read paths
Repository Patterns
- Use projections for lightweight queries:
Transactions
- Annotate service methods with
@Transactional - Use
@Transactional(readOnly = true)for read paths to optimize - Choose propagation carefully; avoid long-running transactions
Pagination
For cursor-like pagination, include id > :lastId in JPQL with ordering.
Indexing and Performance
- Add indexes for common filters (
status,slug, foreign keys) - Use composite indexes matching query patterns (
status, created_at) - Avoid
select *; project only needed columns - Batch writes with
saveAllandhibernate.jdbc.batch_size
Connection Pooling (HikariCP)
Recommended properties:
For PostgreSQL LOB handling, add:
Caching
- 1st-level cache is per EntityManager; avoid keeping entities across transactions
- For read-heavy entities, consider second-level cache cautiously; validate eviction strategy
Migrations
- Use Flyway or Liquibase; never rely on Hibernate auto DDL in production
- Keep migrations idempotent and additive; avoid dropping columns without plan
Testing Data Access
- Prefer
@DataJpaTestwith Testcontainers to mirror production - Assert SQL efficiency using logs: set
logging.level.org.hibernate.SQL=DEBUGandlogging.level.org.hibernate.orm.jdbc.bind=TRACEfor parameter values
Remember: Keep entities lean, queries intentional, and transactions short. Prevent N+1 with fetch strategies and projections, and index for your read/write paths.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingassets/skills/jpa-patterns/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/walterfan/lazy-ai-primer/jpa-patterns)