jpa-patterns

jpa-patterns is a skill for Claude Code, Kiro from affaan-m/ECC. It costs 33 tokens per session (1,111 once invoked), scanned A, original, MIT.

A collection of JPA and Hibernate patterns for Java applications, especially Spring Boot. JPA and Hibernate map Java objects to database tables and provide tools for queries, relationships, transactions, and caching.

In plain words
What is it for?
Use it to design entities and repositories, optimize queries, configure relationships, add auditing or soft deletes, paginate results, and tune connection pools.
Why use it?
It helps avoid slow queries, incorrect relationships, transaction mistakes, and poorly structured database code.

Skill for Claude CodeKiro

Written for Claude Code and Kiro: shipped in a Claude Code plugin, but also installed under .kiro/.

Part of the ecc plugin — 70 skills, 56 commands, 68 agents, 1 MCP server shipped together

About the project

ECC is a toolkit that organizes and improves how coding agents work through skills, memory, security checks, research practices, and related extensions. It is for developers using agents such as Claude Code, Codex, OpenCode, and Cursor.

affaan-m/ECC · 248,541 stars · on GitHub · ecc.tools

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/affaan-m/ecc/jpa-patterns
Any agent
npx skills add affaan-m/ECC --skill jpa-patterns
Clone the repo
git clone --depth 1 https://github.com/affaan-m/ECC

Made for: Claude Code, Kiro.

Or install ecc, the plugin that ships this one along with the rest of its 70 skills, 56 commands, 68 agents, 1 MCP server.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for jpa-patterns

README.md
[![agentmods](https://agentmods.dev/badge/skills/affaan-m/ecc/jpa-patterns.svg)](https://agentmods.dev/skills/affaan-m/ecc/jpa-patterns)
Your own site
<a href="https://agentmods.dev/skills/affaan-m/ecc/jpa-patterns"><img src="https://agentmods.dev/badge/skills/affaan-m/ecc/jpa-patterns.svg" alt="Measured on agentmods" height="20"></a>
Per session 33 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,111 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00033 $0.01111
Opus 5 $0.00016 $0.00556
Sonnet 5 $0.00007 $0.00222
Haiku 4.5 $0.00003 $0.00111

Measured 2d ago against content hash f4b5c3a53d97, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

Grade A, and why

jpa-patterns scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

Copies of this mod

8 near-identical copies found in the catalogue:

.kiro/skills/jpa-patterns/SKILL.md · 154 lines

How it starts

The opening of the file, as written. The whole thing — 154 lines — stays where its author put it; the contents beside it link to each section on GitHub.

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 {}

Relationships and N+1 Prevention

@OneToMany(mappedBy = "market", cascade = CascadeType.ALL, orphanRemoval = true)
private List<PositionEntity> positions = new ArrayList<>();
  • Default to lazy loading; use JOIN FETCH in queries when needed
  • Avoid EAGER on collections; use DTO projections for read paths
@Query("select distinct m from MarketEntity m left join fetch m.positions where m.id = :id")
Optional<MarketEntity> findWithPositions(@Param("id") Long id);

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.

Read the full file on GitHub · 154 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 154 lines · 33 tokens per session scan A f4b5c3a53d97

Subscribe to this mod's changes

jpa-patterns is a skill published in the GitHub repository affaan-m/ECC (248,541 stars, last pushed yesterday), licensed MIT. It adds 33 tokens to every session and 1,111 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.

Related

Other skills, from other repositories

azure-data-tables-java

Build table storage applications with Azure Tables SDK for Java. Use when working with Azure Table Storage or Cosmos DB Table API for NoSQL key-value data, schemaless storage, or structured data at scale.

microsoft/skills · 47 tokens

azure-cosmos-java

Azure Cosmos DB SDK for Java. NoSQL database operations with global distribution, multi-model support, and reactive patterns. Triggers: "CosmosClient java", "CosmosAsyncClient", "cosmos database java", "cosmosdb java", "document database java".

microsoft/skills · 59 tokens

jpa-patterns

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.

decebals/claude-code-java · 47 tokens

oryxos-init

初始化 OryxOS(或同类 JDK 21 + Spring Boot 3.x 企业级单体)的工程地基:Maven 多模块骨架、 结构化日志、Actuator + Prometheus 监控、Spring MVC + 虚拟线程、springdoc OpenAPI、 统一响应体与全局异常/错误码、Google 格式 + 阿里编码规约(Spotless + 阿里 P3C + Checkstyle)、 代码安全检查(SpotBugs + Find Security Bugs + PMD + OWASP Dependency-Check),以及 CI 与 pre-commit。 当用户要「初始化项目 / 搭工程骨架 / 起脚手架 /…

oryx-labs/oryxos · 165 tokens

anyline

AnyLine数据库操作开发规范,涵盖动态数据源注册切换注销、DDL动态建表改表、DML增删改与事务管理、DQL动态查询与聚合统计、元数据管理、查询结果集的聚合、过滤、格式转换等数学计算,AnyLine方法内部会自动适配100+数据库方言,调用方法时忽略不同数据库差异。.

anylineorg/anyline · 88 tokens

413-frameworks-quarkus-db-migrations-flyway

Use when you need to add or review Flyway database migrations in a Quarkus application — quarkus-flyway extension, db/migration scripts, quarkus.flyway. configuration, migrate-at-start, and alignment with JDBC or Panache. This should trigger for requests such as Add or review Flyway migrations in a Quarkus project…

jabrena/plinth · 136 tokens