- 必须使用 @Repository 注解仓库类。
- 仓库类必须是接口类型。
- 必须继承 JpaRepository,并将实体和实体 ID 作为参数,除非在提示中另有说明。
- 所有 @Query 类型的方法必须使用 JPQL,除非在提示中另有说明。
- 在关系查询中必须使用 @EntityGraph(attributePaths={"relatedEntity"}) 以避免 N+1 问题。
- 对于使用 @Query 的多表连接查询,必须使用 DTO 作为数据容器。
Springboot Jpa Repository Class Conventions
规定了仓库(Repository)类的结构和功能,强调使用 JpaRepository、JPQL 查询和 EntityGraph 来防止 N+1 问题。
Springboot Jpa Repository Class Conventions by liaosw97 · 34f850f
npx skillmds@latest add liaosw97/springboot-jpa-repository-class-conventions File contents
---name: springboot-jpa-repository-class-conventionsdescription: 规定了仓库(Repository)类的结构和功能,强调使用 JpaRepository、JPQL 查询和 EntityGraph 来防止 N+1 问题。---- 必须使用 @Repository 注解仓库类。- 仓库类必须是接口类型。- 必须继承 JpaRepository,并将实体和实体 ID 作为参数,除非在提示中另有说明。- 所有 @Query 类型的方法必须使用 JPQL,除非在提示中另有说明。- 在关系查询中必须使用 @EntityGraph(attributePaths={"relatedEntity"}) 以避免 N+1 问题。- 对于使用 @Query 的多表连接查询,必须使用 DTO 作为数据容器。
liaosw97/awesome-rules-skills/tree/main/plugins/springboot/skills/springboot-jpa-repository-class-conventions commit 34f850f8df
Frequently asked questions
Run npx skillmds@latest add liaosw97/springboot-jpa-repository-class-conventions in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
规定了仓库(Repository)类的结构和功能,强调使用 JpaRepository、JPQL 查询和 EntityGraph 来防止 N+1 问题。 It is listed under Coding & Dev Tools on SkillMD.
This skill has not completed SkillMD's automated safety review yet. Capability flags: docs only. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
liaosw97 (@liaosw97) published this skill. Their other Agent Skills are listed on their SkillMD profile.