MCPInstall

java-jpa-hibernate

Master JPA/Hibernate - entity design, queries, transactions, performance optimization

Installs
614
Last 24h
—
Trending rank
—
Security
Not audited

Install

Works with every agent the skills CLI supports.

npx skills add https://github.com/pluginagentmarketplace/custom-plugin-java --skill java-jpa-hibernate
  1. 01

    Install

    Run the command in your project. The CLI asks which agents to install for.

  2. 02

    Describe the task

    Ask your agent for something this skill covers. It loads java-jpa-hibernate automatically when relevant.

  3. 03

    Review the result

    The agent follows the SKILL.md steps, scripts and references bundled with the skill.

SKILL.md

The instructions your agent reads when the skill is triggered.

Java JPA Hibernate Skill

Master data persistence with JPA and Hibernate for production applications.

Overview

This skill covers JPA entity design, Hibernate optimization, Spring Data repositories, query strategies, and caching. Focuses on preventing N+1 queries and building high-performance persistence layers.

When to Use This Skill

Use when you need to:

  • Design JPA entities with relationships
  • Optimize database queries
  • Configure Hibernate for performance
  • Implement caching strategies
  • Debug persistence issues

Topics Covered

Entity Design

  • Entity mapping annotations
  • Relationship types (1:1, 1:N, N:M)
  • Inheritance strategies
  • Lifecycle callbacks
  • Auditing

Query Optimization

  • N+1 problem prevention
  • JOIN FETCH vs EntityGraph
  • Batch fetching
  • Projections and DTOs

Transactions

  • @Transactional configuration
  • Propagation and isolation
  • Optimistic vs pessimistic locking
  • Deadlock prevention

Caching

  • First and second level cache
  • Query cache
  • Cache invalidation
  • Redis integration

Quick Reference

// Entity with relationships
@Entity
@Table(name = "orders")
public class Order {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "customer_id", nullable = false)
    private Customer customer;

    @OneToMany(mappedBy = "order", cascade = CascadeType.ALL, orphanRemoval = true)
    @BatchSize(size = 20)
    private List<OrderItem> items = new ArrayList<>();

    @Version
    private Long version;

    // Bidirectional helper
    public void addItem(OrderItem item) {
        items.add(item);
        item.setOrder(this);
    }
}

// Auditing base class
@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
public abstract class Auditable {
    @CreatedDate
    @Column(updatable = false)
    private Instant createdAt;

    @LastModifiedDate
    private Instant updatedAt;
}

// Repository with query optimization
public interface OrderRepository extends JpaRepository<Order, Long> {

    // JOIN FETCH to prevent N+1
    @Query("SELECT DISTINCT o FROM Order o JOIN FETCH o.items WHERE o.status = :status")
    List<Order> findByStatusWithItems(@Param("status") Status status);

    // EntityGraph alternative
    @EntityGraph(attributePaths = {"items", "customer"})
    Optional<Order> findById(Long id);

    // DTO Projection
    @Query("SELECT new com.example.OrderSummary(o.id, o.status, c.name) " +
           "FROM Order o JOIN o.customer c WHERE o.id = :id")
    Optional<OrderSummary> findSummaryById(@Param("id") Long id);
}

N+1 Prevention Strategies

StrategyUse WhenExample
JOIN FETCHAlways need relationJOIN FETCH o.items
EntityGraphDynamic fetching@EntityGraph(attributePaths)
@BatchSizeCollection access@BatchSize(size = 20)
DTO ProjectionRead-only queriesnew OrderSummary(...)

Hibernate Configuration

spring:
  jpa:
    open-in-view: false  # Critical!
    properties:
      hibernate:
        jdbc.batch_size: 50
        order_inserts: true
        order_updates: true
        default_batch_fetch_size: 20
        generate_statistics: ${HIBERNATE_STATS:false}

  datasource:
    hikari:
      maximum-pool-size: 20
      minimum-idle: 5
      leak-detection-threshold: 60000

Troubleshooting

Common Issues

ProblemCauseSolution
N+1 queriesLazy in loopJOIN FETCH, EntityGraph
LazyInitExceptionSession closedDTO projection
Slow queriesMissing indexEXPLAIN ANALYZE
Connection leakNo @TransactionalAdd annotation

Debug Properties

spring.jpa.show-sql=true
logging.level.org.hibernate.SQL=DEBUG
logging.level.org.hibernate.orm.jdbc.bind=TRACE
hibernate.generate_statistics=true

Debug Checklist

□ Enable SQL logging
□ Check query count per request
□ Verify fetch strategies
□ Review @Transactional
□ Check connection pool

Usage

Skill("java-jpa-hibernate")

Related Skills

  • java-performance - Query optimization
  • java-spring-boot - Spring Data

FAQ

What does the java-jpa-hibernate skill do?

Master JPA/Hibernate - entity design, queries, transactions, performance optimization

How do I install java-jpa-hibernate?

Run npx skills add https://github.com/pluginagentmarketplace/custom-plugin-java --skill java-jpa-hibernate in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/java-jpa-hibernate/ (personal) or .claude/skills/java-jpa-hibernate/ (project).

Which AI agents can use java-jpa-hibernate?

Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.

Is java-jpa-hibernate safe to install?

No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.

Who maintains java-jpa-hibernate?

It is published by pluginagentmarketplace in pluginagentmarketplace/custom-plugin-java. It has 614 recorded installs.

More from pluginagentmarketplace/custom-plugin-java

View all →

java-spring-boot

pluginagentmarketplace/custom-plugin-java

Build production Spring Boot applications - REST APIs, Security, Data, Actuator

Backend & APIs11.8K installs

java-testing

pluginagentmarketplace/custom-plugin-java

Test Java applications - JUnit 5, Mockito, integration testing, TDD patterns

Testing & QA904 installs

java-maven

pluginagentmarketplace/custom-plugin-java

Master Apache Maven - POM configuration, plugins, lifecycle, dependency management

Backend & APIs896 installs

java-fundamentals

pluginagentmarketplace/custom-plugin-java

Master core Java programming - syntax, OOP, collections, streams, and exception handling

Backend & APIs619 installs

java-microservices

pluginagentmarketplace/custom-plugin-java

Build microservices - Spring Cloud, service mesh, event-driven, resilience patterns

Backend & APIs499 installs

java-performance

pluginagentmarketplace/custom-plugin-java

JVM performance tuning - GC optimization, profiling, memory analysis, benchmarking

Backend & APIs483 installs

Popular backend & apis skills

View category →

find-skills

vercel-labs/skills

Helps users discover and install agent skills when they ask questions like "how do I do X", "find a skill for X", "is there a skill that can...", or express interest in extending capabilities. This skill should be used when the user is looking for functionality that might exist as an installable skill.

OfficialBackend & APIs4.1M installs

entra-app-registration

microsoft/azure-skills

Guides Microsoft Entra ID app registration, OAuth 2.0 authentication, and MSAL integration. USE FOR: create app registration, register Azure AD app, configure OAuth, set up authentication, add API permissions, generate service principal, MSAL example, console app auth, Entra ID setup, Azure AD authentication. DO NOT USE FOR: Key Vault secrets (use azure-keyvault-expiration-audit), general Azure resource security guidance.

OfficialBackend & APIs566.7K installs

This skill should be used when the user wants to "write agent code", "build an agent with ADK", "add a tool", "create a callback", "define an agent", "use state management" — in a project that needs ADK (Agent Development Kit) API patterns and code examples. It provides a quick reference for agent types, tool definitions, orchestration patterns, callbacks, state management, the graph Workflow API, and reference recipes to study. Do NOT use for scaffolding (use google-agents-cli-scaffold) or deployment (use google-agents-cli-deploy).

Backend & APIs514.8K installs

embedded-captions

heygen-com/hyperframes

Add captions or subtitles to an existing single-subject talking-head video without editing the footage. Use for plain verbatim captions, cinematic captions embedded behind the subject, VFX captions, “炸/特效/酷炫字幕,” or a named identity from the 35-style catalog. Route by visual identity, not by backend engine. The quiet anchor rail is the default; embed every word only when the user explicitly wants a fully cinematic treatment. The workflow runs locally end to end, including transcription and subject matting; split multi-shot footage before applying it.

Backend & APIs453.3K installs

entra-agent-id

microsoft/azure-skills

Provision Microsoft Entra Agent Identity Blueprints, BlueprintPrincipals, and per-instance Agent Identities via Microsoft Graph, and configure OAuth 2.0 token exchange (fmipath, OBO, cross-tenant) including the Microsoft Entra SDK for AgentID sidecar. USE FOR: Agent Identity Blueprint, BlueprintPrincipal, agent OAuth, fmipath token exchange, agent OBO, Workload Identity Federation for agents, polyglot agent auth, Microsoft.Identity.Web.AgentIdentities. DO NOT USE FOR: standard Entra app registration (use entra-app-registration), Microsoft Foundry agent authoring (use microsoft-foundry).

OfficialBackend & APIs336.6K installs

neon

neondatabase/agent-skills

Overview of Neon, a complete set of cloud backend primitives around Lakebase Postgres: Auth, Object Storage, Functions, the AI Gateway, and Realtime. Start here to choose Neon for undecided login, files, APIs, and LLM calls, set up the CLI or MCP server, and follow the branch-first workflow. Use when building an app or backend on Neon, or when "Neon" or "Lakebase Postgres" is mentioned. Child skill neon-postgres wins for an existing DATABASEURL, SQL, schema, inspect, or search. Child skill neon-auth wins for login, users, sessions, identity routing, and Managed Better Auth setup. Child skill neon-realtime wins for live queries in reactive apps and agents. Also use for object storage, S3, buckets, serverless functions, function triggers, cron, AI gateway, LLM calls, realtime, logs, Loki, Grafana, observability, postgres, database, backend, Claimable Neon, neon.new, or a no-signup database.

Backend & APIs237.1K installs