Agent skill · software engineering · affaan-m

jpa-patterns

JPA/Hibernate patterns for entity design, relationships, query optimization, transactions, auditing, indexing, pagination, and pooling in Spring Boot.

Why this skill is useful

Provides specific JPA/Hibernate patterns and optimizations that enhance performance and entity design in Spring Boot applications.

What it needs

About 2k tokens when loaded. Last updated 2026-08-06. 238,342 stars on the source repository.

What this skill does

JPA/Hibernate Patterns Use for data modeling, repositories, and performance tuning in Spring Boot. When to Activate Designing JPA entities and table mappings Defining relationships (@OneToMany, @ManyToOne, @ManyToMany) Optimizing queries (N+1 prevention, fetch strategies, projections) Configuring transactions, auditing, or soft deletes Setting up pagination, sorting, or custom repository methods Tuning connection pooling (HikariCP) or second-level caching Entity Design Enable auditing: Relationships and N+1 Prevention Default to lazy loading; use JOIN FETCH in queries when needed Avoid EAGER on collections; use DTO projections for read paths Note: DISTINCT is required when fetch-joining a one-to-many collection — without it, the root entity is duplicated once per child row in the result set. For single-result queries (findById) the duplication is harmless, but for list queries it produces duplicate root objects. Hibernate 6+ applies de-duplication automatically in some cases, but explicit DISTINCT keeps behavior portable and clear. 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. …

How to use it

Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:

@skills affaan-m/jpa-patterns--50081c

View the source on GitHub

Browse the @skills marketplace