Covers the classic JPA pain points you'll eventually hit in any Spring Boot app: N+1 queries killing performance, LazyInitializationException blowing up outside transactions, and the EAGER vs LAZY debate. The quick reference table maps symptoms to fixes, which is handy when you're staring at Hibernate logs. Heavy focus on JOIN FETCH, EntityGraph, and DTO projections as practical solutions. Also walks through transaction propagation, which matters more than people think when you're dealing with nested service calls. The examples are realistic, showing both the broken patterns and working alternatives. If you're debugging why your app suddenly fires 500 queries on a simple list endpoint, this will save you time.

skills.sh installs
297
GitHub stars
771
last updated
Feb 8, 2026

Install

$ npx -y skills add decebals/claude-code-java --skill jpa-patterns --agent claude-code

Installs into .claude/skills of the current project.

Files

JPA Patterns Skill

Best practices and common pitfalls for JPA/Hibernate in Spring applications.

When to Use

  • User mentions "N+1 problem" / "too many queries"
  • LazyInitializationException errors
  • Questions about fetch strategies (EAGER vs LAZY)
  • Transaction management issues
  • Entity relationship design
  • Query optimization

Quick Reference: Common Problems

ProblemSymptomSolution
N+1 queriesMany SELECT statementsJOIN FETCH, @EntityGraph
LazyInitializationExceptionError outside transactionOpen Session in View, DTO projection, JOIN FETCH
Slow queriesPerformance issuesPagination, projections, indexes
Dirty checking overheadSlow updatesRead-only transactions, DTOs
Lost updatesConcurrent modificationsOptimistic locking (@Version)

N+1 Problem

The #1 JPA performance killer

The Problem

// ❌ BAD: N+1 queries
@Entity
public class Author {
    @Id private Long id;
    private String name;

    @OneToMany(mappedBy = "author", fetch = FetchType.LAZY)
    private List<Book> books;
}

Sponsors

Details

Repository
github.com/decebals/claude-code-java
Categories
Debugging, Java & JVM
License
MIT
First seen
Jun 11, 2026

More from decebals/claude-code-java

All 18

Recommended

More Debugging
1tech-leads-club avatarplaywright-skilltech-leads-club/agent-skillsComplete browser automation with Playwright. Auto-detects dev servers, writes clean test scripts to /tmp. Test pages, fill forms, take screenshots, check respon297skills.sh installs
2krutikjain avatarandroid-networking-retrofit-okhttpkrutikjain/android-agent-skillsBuild Android networking stacks with Retrofit, OkHttp, interceptors, API contracts, and resilient error handling.296skills.sh installs
3desplega-ai avatarqa-usedesplega-ai/qa-useE2E testing and browser automation with qa-use CLI. Use when the user needs to run tests, verify features, automate browser interactions, or debug test failures295skills.sh installs
4personamanagmentlayer avatartableau-expertpersonamanagmentlayer/pclExpert-level Tableau Desktop/Server, calculated fields, LOD expressions, dashboards, data blending, and performance optimization294skills.sh installs
5lyndonkl avatarchef-assistantlyndonkl/claudeGuides cooking through culinary principles, food science, and flavor architecture rather than rote recipe steps. Covers technique teaching (knife skills, sauces284skills.sh installs
6charleswiltgen avataraxiom-swiftui-26-refcharleswiltgen/axiomUse when implementing iOS 26 SwiftUI features - covers Liquid Glass design system, performance improvements, @Animatable macro, 3D spatial layout, scene bridgin281skills.sh installs