jpa-patterns

Identify and fix JPA performance issues and lazy loading problems in Spring applications.

700|137|Updated Jan 30, 2026
One-click install
npx skills add https://github.com/decebals/claude-code-java --skill jpa-patterns-decebals
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: jpa-patterns
Source: https://github.com/decebals/claude-code-java/tree/main/.claude/skills/jpa-patterns
Command: npx skills add https://github.com/decebals/claude-code-java --skill jpa-patterns-decebals

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

JPA/Hibernate patterns and common pitfalls (N+1, lazy loading, transactions, queries). Use when user has JPA performance issues, LazyInitializationException, or asks about entity relationships and fetching strategies.

Core Features & Use Cases

  • N+1 problem detection and fixes with JOIN FETCH, EntityGraph, batch fetching
  • Lazy loading strategies and prevention of LazyInitializationException
  • Transaction handling, propagation, and consistency
  • Entity relationship best practices and query optimization

Quick Start

Review your JPA usage and apply these patterns to resolve N+1, lazy loading, and transactional issues.

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 JPA N+1 query problem in my Spring application?

Fix the JPA N+1 query problem by applying proven patterns like JOIN FETCH, EntityGraph, or batch fetching to optimize complex entity relationships and drastically reduce high query counts in Spring Data JPA.

Why does LazyInitializationException occur and how can I prevent it?

LazyInitializationException occurs when accessing lazily loaded entity relationships outside a transaction; prevent it by applying proper transaction handling, fetching strategies, and guided refactoring best practices in Hibernate.

What's the best way to optimize JPA transactions and propagation?

The best way to optimize JPA transactions is to enforce best practices for transaction handling, propagation, and consistency, enabling targeted query optimizations and resolving performance issues through guided refactors.

Does this approach work with Spring Data JPA and Hibernate fetching strategies?

Yes, this approach works directly with Spring Data JPA and Hibernate to apply best practices for entity relationships, query optimization, and fetching strategies, resolving complex performance bottlenecks.

How do I detect high query counts and resolve JPA performance issues?

Detect high query counts and resolve JPA performance issues through code reviews that identify N+1 problems, lazy loading pitfalls, and transactional inconsistencies, applying actionable patterns and targeted optimizations.