Jpa Patterns
JPA/Hibernate 模式,涵盖 Spring Boot 中的实体设计、关系、查询优化、事务、审计、索引、分页和连接池。
Install
/plugin marketplace add xu-xiang/everything-claude-code-zhThe repo is a Claude Code plugin marketplace. Run /plugin afterwards to pick the plugin that includes this skill.
npx skills add xu-xiang/everything-claude-code-zh --skill jpa-patternsgit clone --depth 1 https://github.com/xu-xiang/everything-claude-code-zh.git /tmp/everything-claude-code-zh
mkdir -p ~/.claude/skills
cp -r /tmp/everything-claude-code-zh/skills/jpa-patterns ~/.claude/skills/jpa-patternsPersonal skills live in ~/.claude/skills. Use .claude/skills in a project folder to share a skill with your team.
From the SKILL.md
# JPA/Hibernate 模式
用于 Spring Boot 中的数据建模、仓库层(Repositories)实现和性能调优。
## 何时激活
- 设计 JPA 实体(Entities)和表映射
- 定义关联关系(@OneToMany、@ManyToOne、@ManyToMany)
- 优化查询(防止 N+1 问题、抓取策略、投影)
- 配置事务、审计(Auditing)或逻辑删除
- 设置分页、排序或自定义 Repository 方法
- 调优连接池(HikariCP)或二级缓存(Second-level Caching)
## 实体设计
```java
@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;
}
```
启用审计(Auditing):
```java
@Configuration
@EnableJpaAuditing
class JpaConfig {}
```
## 关联关系与防止 N+1 问题
```java
@OneToMany(mappedBy = "market", cascade = CascadeType.ALL, orphanRemoval = true)
private List<PositionEntity> positions = new ArrayList<>();
```
- 默认使用延迟加载(Lazy Loading);必要时在查询中使用 `JOIN FETCH`
- 避免在集合上使用 `EAGER`;在读取路径中使用 DTO 投影(Projections)
```java
@Query("select m from MarketEntity m left join fetch m.positions where m.id = :id")
Optional<MarketEntity> findWithPositions(@Param("id") Long id);
```
## Repository 模式Details
- Skill name
jpa-patterns- Repository
- xu-xiang/everything-claude-code-zh
- Path
skills/jpa-patterns/SKILL.md- License
- MIT
- Repo updated
- 5 March 2026
FAQ
What does the Jpa Patterns skill do?
JPA/Hibernate 模式,涵盖 Spring Boot 中的实体设计、关系、查询优化、事务、审计、索引、分页和连接池。
How do I install the Jpa Patterns skill?
Claude Code plugin: /plugin marketplace add xu-xiang/everything-claude-code-zh. Skills go in ~/.claude/skills (personal) or .claude/skills (project), and Claude loads them automatically when a task matches the description.
Is Jpa Patterns popular?
It lives in xu-xiang/everything-claude-code-zh, which has 2,037 GitHub stars and 332 forks.
Related skills
Backend Patterns
2kxu-xiang/everything-claude-code-zh
Backend architecture patterns, API design, database optimization, and server-side best practices for Node.js, Express, and Next.js API routes.
Coding Standards
2kxu-xiang/everything-claude-code-zh
Universal coding standards, best practices, and patterns for TypeScript, JavaScript, React, and Node.js development.
Frontend Patterns
2kxu-xiang/everything-claude-code-zh
Frontend development patterns for React, Next.js, state management, performance optimization, and UI best practices.
Strategic Compact
2kxu-xiang/everything-claude-code-zh
建议在逻辑间隔进行手动上下文压缩(Context Compaction),以便在任务阶段中保留上下文,而不是依赖任意的自动压缩。
Jpa Patterns
2kxu-xiang/everything-claude-code-zh
Spring Boot 中用于实体设计、关联关系、查询优化、事务、审计、索引、分页和连接池的 JPA/Hibernate 模式。
Strategic Compact
2kxu-xiang/everything-claude-code-zh
建议在逻辑间隔处进行手动压缩(Manual Compaction),以在整个任务阶段保持上下文(Context),而非随意的自动压缩。
Browse the most popular Claude skills, all other skills, or write your own with the skills generator.