Skip to content
affaan-m avatar

Jpa Patterns

JPA and Hibernate patterns for entities, N+1 fixes, transactions, pagination, and HikariCP tuning in Spring Boot.

CCM score
71 of 100
skills.sh installs
13K
GitHub stars
312.6K
last updated
Aug 21, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers entity mapping, relationships, repository queries, transactions, auditing, pagination, indexing, connection pooling, and migrations
  • Includes Java examples for @Entity mapping, JOIN FETCH queries, DTO projections, and @Transactional service methods
  • Enforces lazy loading over EAGER collections, plus Flyway or Liquibase migrations instead of Hibernate auto DDL in production
  • Designed for Spring Boot services that query relational databases through JPA and need N+1 or pooling fixes

Install

$ npx -y skills add affaan-m/ecc --skill jpa-patterns -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

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

@Entity
@Table(name = "markets", indexes = {
  @Index(name = "idx_markets_slug", columnList = "slug", unique = true)
})
@EntityListeners(AuditingEntityListener.class)
public class MarketEntity {
  @Id @GeneratedValue(strategy = GenerationType.IDENTITY)
  private Long id;

  @Column(nullable = false, length = 200)
  private String name;

  @Column(nullable = false, unique = true, length = 120)
  private String slug;

  @Enumerated(EnumType.STRING)
  private MarketStatus status = MarketStatus.ACTIVE;

  @CreatedDate private Instant createdAt;
  @LastModifiedDate private Instant updatedAt;
}

Enable auditing:

@Configuration
@EnableJpaAuditing
class JpaConfig {}

Details

Repository
github.com/affaan-m/ecc
Categories
Java & JVM, Databases
First seen
Jul 14, 2026

Questions

What does the jpa-patterns skill help with in Spring Boot?

The jpa-patterns skill covers JPA and Hibernate patterns for entity design, relationships, query optimization, transactions, auditing, indexing, pagination, and connection pooling in Spring Boot. It is meant for data modeling, repositories, and performance tuning. It applies when designing JPA entities or fixing a Hibernate query, transaction, or N+1 problem.

How do I install the jpa-patterns skill?

Run npx -y skills add affaan-m/ecc --skill jpa-patterns -y in your project to install it. Once installed, the agent can apply JPA and Hibernate guidance to your Spring Boot code. The skill comes from the affaan-m/ecc repository on GitHub.

Where does jpa-patterns rank among Java and JVM skills?

The jpa-patterns skill sits in the Java and JVM category and ranks in the top 10 on that category page. Other skills in the category include java-springboot, springboot-patterns, java-coding-standards, kotlin-patterns, and springboot-verification. Its focus on JPA entities, queries, and transactions sets it apart from these broader Spring and Java guides.

Does jpa-patterns help with N+1 query problems in Hibernate?

Yes, the skill covers N+1 prevention through lazy loading, JOIN FETCH in queries, and DTO projections for read paths. It also advises against EAGER fetching on collections. These patterns help when a Hibernate query triggers many extra SQL statements.

What does jpa-patterns say about database migrations and testing?

The skill advises using Flyway or Liquibase for migrations and never relying on Hibernate auto DDL in production. For testing, it recommends @DataJpaTest with Testcontainers and logging Hibernate SQL to check query efficiency.

More from affaan-m/ecc

All 257

Similar to Jpa Patterns

More Java & JVM