jpa-patterns

Model and tune Spring Boot data access with JPA and Hibernate patterns.

40|8|Updated Jan 23, 2026
One-click install
npx skills add https://github.com/ysyecust/everything-claude-code --skill jpa-patterns-ysyecust
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: jpa-patterns
Source: https://github.com/ysyecust/everything-claude-code/tree/main/skills/jpa-patterns
Command: npx skills add https://github.com/ysyecust/everything-claude-code --skill jpa-patterns-ysyecust

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Building and maintaining a scalable data access layer in Spring Boot can be error-prone. This Skill provides a consolidated set of JPA/Hibernate patterns to design lean entities, reliable relationships, and efficient queries, reducing boilerplate and preventing common performance pitfalls.

Core Features & Use Cases

  • Entity design guidelines: Lean, auditable entities with sensible defaults and clear ownership.
  • Relationship and query patterns: Lazy loading, fetch joins, and DTO projections to avoid N+1 and oversized results.
  • Transactions and performance: Proper transactional boundaries, propagation, batching, and indexing strategies to optimize write and read paths.
  • Use Case: Model a typical domain (e.g., e-commerce) with products, orders, and customers, ensuring consistent auditing and scalable reads.

Quick Start

Use these patterns to audit and refactor a Spring Data JPA layer by reviewing entities, repositories, and queries for lazy vs eager loading, fetch joins, and projection usage.

Frequently Asked Questions about jpa-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix the N+1 problem in Spring Data JPA?

To fix the N+1 problem in Spring Data JPA, apply fetch joins and DTO projections to optimize lazy loading. This Skill provides patterns for selecting the correct loading strategy and query structure to avoid oversized results and redundant database calls.

How do I design JPA entities to avoid common performance pitfalls?

Designing JPA entities requires lean structures with clear ownership and sensible defaults. This Skill provides guidelines for building auditable entities, defining reliable relationships, and establishing indexing strategies to prevent common Hibernate performance issues.

What is the best way to handle JPA pagination and transactional boundaries?

Handling JPA pagination and transactional boundaries requires proper transaction propagation and query limits. This Skill specifies practical requirements for transactional boundaries, batching, and scalable read paths to manage large datasets efficiently.

Does this Skill cover auditing and safe migrations for Hibernate?

Yes, this Skill covers auditing and safe migrations for Hibernate. It specifies patterns for consistent entity auditing and safe schema migrations, ensuring your Spring Boot data access layer remains scalable and maintainable during domain model evolution.

When should I use lazy loading vs eager loading in Spring Boot?

Use lazy loading to prevent fetching unnecessary data and eager loading only when associations are always needed. This Skill helps you review entities and queries to balance loading strategies, applying fetch joins and projections to ensure scalable reads.