[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7AM3AWT8KGM94DDYYZG69MC":3,"skill-same:01M7AM3AWT8KGM94DDYYZG69MC":48},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":25,"commitSha":26,"skillDirectory":27,"forksCount":28,"repositoryHtmlUrl":29,"repositoryHomepageUrl":6,"ownerHtmlUrl":30,"ownerBlogUrl":31,"ownerDescription":32,"updatedAt":33,"install":34,"resources":47},"01M7AM3AWT8KGM94DDYYZG69MC","jpa-patterns",null,"Spring Boot中的JPA\u002FHibernate模式，用于实体设计、关系处理、查询优化、事务管理、审计、索引、分页和连接池。","Cyrilthetecchieee\u002Fcyril-code-","Cyrilthetecchieee","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F219787998?v=4","01M7AF0MMMKRAA0H61XMJPV92H","Julian Cyril D ","01M7AF0MQ10AVG6QJQ1C2BC0F5",2,"MIT","https:\u002F\u002Fgithub.com\u002FCyrilthetecchieee\u002Fcyril-code-\u002Fblob\u002Fmain\u002Fsrc\u002Fcyril_code\u002Fassets\u002F.skills_repo\u002Fdocs\u002Fzh-CN\u002Fskills\u002Fjpa-patterns\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: jpa-patterns\ndescription: Spring Boot中的JPA\u002FHibernate模式，用于实体设计、关系处理、查询优化、事务管理、审计、索引、分页和连接池。\norigin: ECC\n---\n\n# JPA\u002FHibernate 模式\n\n用于 Spring Boot 中的数据建模、存储库和性能调优。\n\n## 何时激活\n\n* 设计 JPA 实体和表映射时\n* 定义关系时 (@OneToMany, @ManyToOne, @ManyToMany)\n* 优化查询时 (N+1 问题预防、获取策略、投影)\n* 配置事务、审计或软删除时\n* 设置分页、排序或自定义存储库方法时\n* 调整连接池 (HikariCP) 或二级缓存时\n\n## 实体设计\n\n```java\n@Entity\n@Table(name = \"markets\", indexes = {\n  @Index(name = \"idx_markets_slug\", columnList = \"slug\", unique = true)\n})\n@EntityListeners(AuditingEntityListener.class)\npublic class MarketEntity {\n  @Id @GeneratedValue(strategy = GenerationType.IDENTITY)\n  private Long id;\n\n  @Column(nullable = false, length = 200)\n  private String name;\n\n  @Column(nullable = false, unique = true, length = 120)\n  private String slug;\n\n  @Enumerated(EnumType.STRING)\n  private MarketStatus status = MarketStatus.ACTIVE;\n\n  @CreatedDate private Instant createdAt;\n  @LastModifiedDate private Instant updatedAt;\n}\n```\n\n启用审计：\n\n```java\n@Configuration\n@EnableJpaAuditing\nclass JpaConfig {}\n```\n\n## 关联关系和 N+1 预防\n\n```java\n@OneToMany(mappedBy = \"market\", cascade = CascadeType.ALL, orphanRemoval = true)\nprivate List\u003CPositionEntity> positions = new ArrayList\u003C>();\n```\n\n* 默认使用延迟加载；需要时在查询中使用 `JOIN FETCH`\n* 避免在集合上使用 `EAGER`；对于读取路径使用 DTO 投影\n\n```java\n@Query(\"select m from MarketEntity m left join fetch m.positions where m.id = :id\")\nOptional\u003CMarketEntity> findWithPositions(@Param(\"id\") Long id);\n```\n\n## 存储库模式\n\n```java\npublic interface MarketRepository extends JpaRepository\u003CMarketEntity, Long> {\n  Optional\u003CMarketEntity> findBySlug(String slug);\n\n  @Query(\"select m from MarketEntity m where m.status = :status\")\n  Page\u003CMarketEntity> findByStatus(@Param(\"status\") MarketStatus status, Pageable pageable);\n}\n```\n\n* 使用投影进行轻量级查询：\n\n```java\npublic interface MarketSummary {\n  Long getId();\n  String getName();\n  MarketStatus getStatus();\n}\nPage\u003CMarketSummary> findAllBy(Pageable pageable);\n```\n\n## 事务\n\n* 使用 `@Transactional` 注解服务方法\n* 对读取路径使用 `@Transactional(readOnly = true)` 以进行优化\n* 谨慎选择传播行为；避免长时间运行的事务\n\n```java\n@Transactional\npublic Market updateStatus(Long id, MarketStatus status) {\n  MarketEntity entity = repo.findById(id)\n      .orElseThrow(() -> new EntityNotFoundException(\"Market\"));\n  entity.setStatus(status);\n  return Market.from(entity);\n}\n```\n\n## 分页\n\n```java\nPageRequest page = PageRequest.of(pageNumber, pageSize, Sort.by(\"createdAt\").descending());\nPage\u003CMarketEntity> markets = repo.findByStatus(MarketStatus.ACTIVE, page);\n```\n\n对于类似游标的分页，在 JPQL 中包含 `id > :lastId` 并配合排序。\n\n## 索引和性能\n\n* 为常用过滤器添加索引（`status`、`slug`、外键）\n* 使用与查询模式匹配的复合索引（`status, created_at`）\n* 避免 `select *`；仅投影需要的列\n* 使用 `saveAll` 和 `hibernate.jdbc.batch_size` 进行批量写入\n\n## 连接池 (HikariCP)\n\n推荐属性：\n\n```\nspring.datasource.hikari.maximum-pool-size=20\nspring.datasource.hikari.minimum-idle=5\nspring.datasource.hikari.connection-timeout=30000\nspring.datasource.hikari.validation-timeout=5000\n```\n\n对于 PostgreSQL LOB 处理，添加：\n\n```\nspring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true\n```\n\n## 缓存\n\n* 一级缓存是每个 EntityManager 的；避免在事务之间保持实体\n* 对于读取频繁的实体，谨慎考虑二级缓存；验证驱逐策略\n\n## 迁移\n\n* 使用 Flyway 或 Liquibase；切勿在生产中依赖 Hibernate 自动 DDL\n* 保持迁移的幂等性和可添加性；避免无计划地删除列\n\n## 测试数据访问\n\n* 首选使用 Testcontainers 的 `@DataJpaTest` 来镜像生产环境\n* 使用日志断言 SQL 效率：设置 `logging.level.org.hibernate.SQL=DEBUG` 和 `logging.level.org.hibernate.orm.jdbc.bind=TRACE` 以查看参数值\n\n**请记住**：保持实体精简，查询有针对性，事务简短。通过获取策略和投影来预防 N+1 问题，并根据读写路径建立索引。\n","# JPA\u002FHibernate 模式\n\n用于 Spring Boot 中的数据建模、存储库和性能调优。\n\n## 何时激活\n\n* 设计 JPA 实体和表映射时\n* 定义关系时 (@OneToMany, @ManyToOne, @ManyToMany)\n* 优化查询时 (N+1 问题预防、获取策略、投影)\n* 配置事务、审计或软删除时\n* 设置分页、排序或自定义存储库方法时\n* 调整连接池 (HikariCP) 或二级缓存时\n\n## 实体设计\n\n```java\n@Entity\n@Table(name = \"markets\", indexes = {\n  @Index(name = \"idx_markets_slug\", columnList = \"slug\", unique = true)\n})\n@EntityListeners(AuditingEntityListener.class)\npublic class MarketEntity {\n  @Id @GeneratedValue(strategy = GenerationType.IDENTITY)\n  private Long id;\n\n  @Column(nullable = false, length = 200)\n  private String name;\n\n  @Column(nullable = false, unique = true, length = 120)\n  private String slug;\n\n  @Enumerated(EnumType.STRING)\n  private MarketStatus status = MarketStatus.ACTIVE;\n\n  @CreatedDate private Instant createdAt;\n  @LastModifiedDate private Instant updatedAt;\n}\n```\n\n启用审计：\n\n```java\n@Configuration\n@EnableJpaAuditing\nclass JpaConfig {}\n```\n\n## 关联关系和 N+1 预防\n\n```java\n@OneToMany(mappedBy = \"market\", cascade = CascadeType.ALL, orphanRemoval = true)\nprivate List\u003CPositionEntity> positions = new ArrayList\u003C>();\n```\n\n* 默认使用延迟加载；需要时在查询中使用 `JOIN FETCH`\n* 避免在集合上使用 `EAGER`；对于读取路径使用 DTO 投影\n\n```java\n@Query(\"select m from MarketEntity m left join fetch m.positions where m.id = :id\")\nOptional\u003CMarketEntity> findWithPositions(@Param(\"id\") Long id);\n```\n\n## 存储库模式\n\n```java\npublic interface MarketRepository extends JpaRepository\u003CMarketEntity, Long> {\n  Optional\u003CMarketEntity> findBySlug(String slug);\n\n  @Query(\"select m from MarketEntity m where m.status = :status\")\n  Page\u003CMarketEntity> findByStatus(@Param(\"status\") MarketStatus status, Pageable pageable);\n}\n```\n\n* 使用投影进行轻量级查询：\n\n```java\npublic interface MarketSummary {\n  Long getId();\n  String getName();\n  MarketStatus getStatus();\n}\nPage\u003CMarketSummary> findAllBy(Pageable pageable);\n```\n\n## 事务\n\n* 使用 `@Transactional` 注解服务方法\n* 对读取路径使用 `@Transactional(readOnly = true)` 以进行优化\n* 谨慎选择传播行为；避免长时间运行的事务\n\n```java\n@Transactional\npublic Market updateStatus(Long id, MarketStatus status) {\n  MarketEntity entity = repo.findById(id)\n      .orElseThrow(() -> new EntityNotFoundException(\"Market\"));\n  entity.setStatus(status);\n  return Market.from(entity);\n}\n```\n\n## 分页\n\n```java\nPageRequest page = PageRequest.of(pageNumber, pageSize, Sort.by(\"createdAt\").descending());\nPage\u003CMarketEntity> markets = repo.findByStatus(MarketStatus.ACTIVE, page);\n```\n\n对于类似游标的分页，在 JPQL 中包含 `id > :lastId` 并配合排序。\n\n## 索引和性能\n\n* 为常用过滤器添加索引（`status`、`slug`、外键）\n* 使用与查询模式匹配的复合索引（`status, created_at`）\n* 避免 `select *`；仅投影需要的列\n* 使用 `saveAll` 和 `hibernate.jdbc.batch_size` 进行批量写入\n\n## 连接池 (HikariCP)\n\n推荐属性：\n\n```\nspring.datasource.hikari.maximum-pool-size=20\nspring.datasource.hikari.minimum-idle=5\nspring.datasource.hikari.connection-timeout=30000\nspring.datasource.hikari.validation-timeout=5000\n```\n\n对于 PostgreSQL LOB 处理，添加：\n\n```\nspring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true\n```\n\n## 缓存\n\n* 一级缓存是每个 EntityManager 的；避免在事务之间保持实体\n* 对于读取频繁的实体，谨慎考虑二级缓存；验证驱逐策略\n\n## 迁移\n\n* 使用 Flyway 或 Liquibase；切勿在生产中依赖 Hibernate 自动 DDL\n* 保持迁移的幂等性和可添加性；避免无计划地删除列\n\n## 测试数据访问\n\n* 首选使用 Testcontainers 的 `@DataJpaTest` 来镜像生产环境\n* 使用日志断言 SQL 效率：设置 `logging.level.org.hibernate.SQL=DEBUG` 和 `logging.level.org.hibernate.orm.jdbc.bind=TRACE` 以查看参数值\n\n**请记住**：保持实体精简，查询有针对性，事务简短。通过获取策略和投影来预防 N+1 问题，并根据读写路径建立索引。\n",{"name":5,"origin":24,"description":7},"ECC","main","57e7aa6b6e03bce1a7d7862ba9c2ec312f7f19b5","src\u002Fcyril_code\u002Fassets\u002F.skills_repo\u002Fdocs\u002Fzh-CN\u002Fskills\u002Fjpa-patterns",0,"https:\u002F\u002Fgithub.com\u002FCyrilthetecchieee\u002Fcyril-code-","https:\u002F\u002Fgithub.com\u002FCyrilthetecchieee","https:\u002F\u002Fwithcyril.me\u002F","Hi, I’m Julian Cyril D, a Computer Science and Business Systems student at PSNACET.\r\nI’m passionate about full-stack development, UI\u002FUX design, and building sma","2026-11-04 23:28:50",{"source":8,"skillName":5,"commands":35,"prompt":45,"zipAvailable":46},[36,39,42],{"tool":37,"command":38},"npx","npx skills add Cyrilthetecchieee\u002Fcyril-code- --skill jpa-patterns",{"tool":40,"command":41},"bunx","bunx skills add Cyrilthetecchieee\u002Fcyril-code- --skill jpa-patterns",{"tool":43,"command":44},"pnpm","pnpm dlx skills add Cyrilthetecchieee\u002Fcyril-code- --skill jpa-patterns","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FCyrilthetecchieee\u002Fcyril-code-\u002Fblob\u002Fmain\u002Fsrc\u002Fcyril_code\u002Fassets\u002F.skills_repo\u002Fdocs\u002Fzh-CN\u002Fskills\u002Fjpa-patterns\u002FSKILL.md",true,[],[49,58,65,73,80,87],{"skillNo":50,"name":51,"nameZh":6,"description":52,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":53,"licenseFileUrl":54,"sourceHtmlUrl":55,"categories":56,"keywords":57,"publishedAt":19},"01M7AQV6CYX8RMC78420V9WZ62","webapp-testing","Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.","Apache-2.0","https:\u002F\u002Fgithub.com\u002FCyrilthetecchieee\u002Fcyril-code-\u002Fblob\u002Fmain\u002Fsrc\u002Fcyril_code\u002Fassets\u002F.skills_repo\u002Fwebapp-testing\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002FCyrilthetecchieee\u002Fcyril-code-\u002Fblob\u002Fmain\u002Fsrc\u002Fcyril_code\u002Fassets\u002F.skills_repo\u002Fwebapp-testing\u002FSKILL.md",[],[],{"skillNo":59,"name":60,"nameZh":6,"description":61,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":62,"categories":63,"keywords":64,"publishedAt":19},"01M7AQV2895N3S1MEX6K76G6G2","youtube-downloader","Download YouTube videos with customizable quality and format options. Use this skill when the user asks to download, save, or grab YouTube videos. Supports various quality settings (best, 1080p, 720p, 480p, 360p), multiple formats (mp4, webm, mkv), and audio-only downloads as MP3.","https:\u002F\u002Fgithub.com\u002FCyrilthetecchieee\u002Fcyril-code-\u002Fblob\u002Fmain\u002Fsrc\u002Fcyril_code\u002Fassets\u002F.skills_repo\u002Fvideo-downloader\u002FSKILL.md",[],[],{"skillNo":66,"name":67,"nameZh":6,"description":68,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":53,"licenseFileUrl":69,"sourceHtmlUrl":70,"categories":71,"keywords":72,"publishedAt":19},"01M7AQTRNX62DNKVZ5GXEHRBKB","theme-factory","Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with colors\u002Ffonts that you can apply to any artifact that has been creating, or can generate a new theme on-the-fly.","https:\u002F\u002Fgithub.com\u002FCyrilthetecchieee\u002Fcyril-code-\u002Fblob\u002Fmain\u002Fsrc\u002Fcyril_code\u002Fassets\u002F.skills_repo\u002Ftheme-factory\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002FCyrilthetecchieee\u002Fcyril-code-\u002Fblob\u002Fmain\u002Fsrc\u002Fcyril_code\u002Fassets\u002F.skills_repo\u002Ftheme-factory\u002FSKILL.md",[],[],{"skillNo":74,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":19},"01M7AQTNNVHAAN9H6DA8T6ZVE0","template-skill","Replace with description of the skill and when Claude should use it.","https:\u002F\u002Fgithub.com\u002FCyrilthetecchieee\u002Fcyril-code-\u002Fblob\u002Fmain\u002Fsrc\u002Fcyril_code\u002Fassets\u002F.skills_repo\u002Ftemplate-skill\u002FSKILL.md",[],[],{"skillNo":81,"name":82,"nameZh":6,"description":83,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":84,"categories":85,"keywords":86,"publishedAt":19},"01M7AQTJ3MQ6AKX152MEX2MYCC","tailored-resume-generator","Analyzes job descriptions and generates tailored resumes that highlight relevant experience, skills, and achievements to maximize interview chances","https:\u002F\u002Fgithub.com\u002FCyrilthetecchieee\u002Fcyril-code-\u002Fblob\u002Fmain\u002Fsrc\u002Fcyril_code\u002Fassets\u002F.skills_repo\u002Ftailored-resume-generator\u002FSKILL.md",[],[],{"skillNo":88,"name":89,"nameZh":6,"description":90,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":53,"licenseFileUrl":91,"sourceHtmlUrl":92,"categories":93,"keywords":94,"publishedAt":19},"01M7AQTD7D5MYET2YWG7HG9WM3","slack-gif-creator","Toolkit for creating animated GIFs optimized for Slack, with validators for size constraints and composable animation primitives. This skill applies when users request animated GIFs or emoji animations for Slack from descriptions like \"make me a GIF for Slack of X doing Y\".","https:\u002F\u002Fgithub.com\u002FCyrilthetecchieee\u002Fcyril-code-\u002Fblob\u002Fmain\u002Fsrc\u002Fcyril_code\u002Fassets\u002F.skills_repo\u002Fslack-gif-creator\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002FCyrilthetecchieee\u002Fcyril-code-\u002Fblob\u002Fmain\u002Fsrc\u002Fcyril_code\u002Fassets\u002F.skills_repo\u002Fslack-gif-creator\u002FSKILL.md",[],[]]