
Jpa Patterns
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-codeInstalls 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
| Problem | Symptom | Solution |
|---|---|---|
| N+1 queries | Many SELECT statements | JOIN FETCH, @EntityGraph |
| LazyInitializationException | Error outside transaction | Open Session in View, DTO projection, JOIN FETCH |
| Slow queries | Performance issues | Pagination, projections, indexes |
| Dirty checking overhead | Slow updates | Read-only transactions, DTOs |
| Lost updates | Concurrent modifications | Optimistic 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- Changelog Generator251
- Git Commit249
- Issue Triage240
- Java Code Review1.1K
- Clean Code427
- Concurrency Review384
- Solid Principles384
- Architecture Review374
- Design Patterns372
- Spring Boot Patterns358
- Java Migration357
- Security Audit347
- Performance Smell Detection341
- Test Quality336
- Api Contract Review315
- Maven Dependency Audit308
- Logging Patterns300