[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6JV4A9ADWAC75WHWREVN5SD":3,"skill-same:01M6JV4A9ADWAC75WHWREVN5SD":72},{"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":23,"publishedAt":42,"linkOnly":43,"markdownContent":44,"markdownBody":45,"frontMatter":46,"refName":48,"commitSha":49,"skillDirectory":50,"forksCount":51,"repositoryHtmlUrl":52,"repositoryHomepageUrl":53,"ownerHtmlUrl":54,"ownerBlogUrl":55,"ownerDescription":56,"updatedAt":57,"install":58,"resources":71},"01M6JV4A9ADWAC75WHWREVN5SD","jpa-patterns",null,"JPA\u002FHibernate patterns for entity design, relationships, query optimization, transactions, auditing, indexing, pagination, and pooling in Spring Boot.","hashgraph-online\u002Fawesome-codex-plugins","hashgraph-online","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F160371962?v=4","01M6CNB6NRJVNNGN14TR01Q6D3","HOL (Hashgraph Online)","01M6JT1HSKKG9V68KQAQGBA7XP",1575,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002FColin4k1024\u002Ftsp\u002Fskills\u002Fjpa-patterns\u002FSKILL.md",[18],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000015","视觉设计","SCENARIO","使用场景",[24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41],"patterns","jpa","jpa patterns","Optimization","transactions","spring","query optimization","hibernate","pagination","design","query","relationships","indexing","spring boot","entity","for","pooling","boot","2026-11-10 10:12:30",false,"---\nname: jpa-patterns\ndescription: JPA\u002FHibernate patterns for entity design, relationships, query optimization, transactions, auditing, indexing, pagination, and pooling in Spring Boot.\norigin: ECC\n---\n\n# JPA\u002FHibernate Patterns\n\nUse for data modeling, repositories, and performance tuning in Spring Boot.\n\n## When to Activate\n\n- Designing JPA entities and table mappings\n- Defining relationships (@OneToMany, @ManyToOne, @ManyToMany)\n- Optimizing queries (N+1 prevention, fetch strategies, projections)\n- Configuring transactions, auditing, or soft deletes\n- Setting up pagination, sorting, or custom repository methods\n- Tuning connection pooling (HikariCP) or second-level caching\n\n## Entity Design\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\nEnable auditing:\n```java\n@Configuration\n@EnableJpaAuditing\nclass JpaConfig {}\n```\n\n## Relationships and N+1 Prevention\n\n```java\n@OneToMany(mappedBy = \"market\", cascade = CascadeType.ALL, orphanRemoval = true)\nprivate List\u003CPositionEntity> positions = new ArrayList\u003C>();\n```\n\n- Default to lazy loading; use `JOIN FETCH` in queries when needed\n- Avoid `EAGER` on collections; use DTO projections for read paths\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## Repository Patterns\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- Use projections for lightweight queries:\n```java\npublic interface MarketSummary {\n  Long getId();\n  String getName();\n  MarketStatus getStatus();\n}\nPage\u003CMarketSummary> findAllBy(Pageable pageable);\n```\n\n## Transactions\n\n- Annotate service methods with `@Transactional`\n- Use `@Transactional(readOnly = true)` for read paths to optimize\n- Choose propagation carefully; avoid long-running transactions\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## Pagination\n\n```java\nPageRequest page = PageRequest.of(pageNumber, pageSize, Sort.by(\"createdAt\").descending());\nPage\u003CMarketEntity> markets = repo.findByStatus(MarketStatus.ACTIVE, page);\n```\n\nFor cursor-like pagination, include `id > :lastId` in JPQL with ordering.\n\n## Indexing and Performance\n\n- Add indexes for common filters (`status`, `slug`, foreign keys)\n- Use composite indexes matching query patterns (`status, created_at`)\n- Avoid `select *`; project only needed columns\n- Batch writes with `saveAll` and `hibernate.jdbc.batch_size`\n\n## Connection Pooling (HikariCP)\n\nRecommended properties:\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\nFor PostgreSQL LOB handling, add:\n```\nspring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true\n```\n\n## Caching\n\n- 1st-level cache is per EntityManager; avoid keeping entities across transactions\n- For read-heavy entities, consider second-level cache cautiously; validate eviction strategy\n\n## Migrations\n\n- Use Flyway or Liquibase; never rely on Hibernate auto DDL in production\n- Keep migrations idempotent and additive; avoid dropping columns without plan\n\n## Testing Data Access\n\n- Prefer `@DataJpaTest` with Testcontainers to mirror production\n- Assert SQL efficiency using logs: set `logging.level.org.hibernate.SQL=DEBUG` and `logging.level.org.hibernate.orm.jdbc.bind=TRACE` for parameter values\n\n**Remember**: Keep entities lean, queries intentional, and transactions short. Prevent N+1 with fetch strategies and projections, and index for your read\u002Fwrite paths.\n","# JPA\u002FHibernate Patterns\n\nUse for data modeling, repositories, and performance tuning in Spring Boot.\n\n## When to Activate\n\n- Designing JPA entities and table mappings\n- Defining relationships (@OneToMany, @ManyToOne, @ManyToMany)\n- Optimizing queries (N+1 prevention, fetch strategies, projections)\n- Configuring transactions, auditing, or soft deletes\n- Setting up pagination, sorting, or custom repository methods\n- Tuning connection pooling (HikariCP) or second-level caching\n\n## Entity Design\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\nEnable auditing:\n```java\n@Configuration\n@EnableJpaAuditing\nclass JpaConfig {}\n```\n\n## Relationships and N+1 Prevention\n\n```java\n@OneToMany(mappedBy = \"market\", cascade = CascadeType.ALL, orphanRemoval = true)\nprivate List\u003CPositionEntity> positions = new ArrayList\u003C>();\n```\n\n- Default to lazy loading; use `JOIN FETCH` in queries when needed\n- Avoid `EAGER` on collections; use DTO projections for read paths\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## Repository Patterns\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- Use projections for lightweight queries:\n```java\npublic interface MarketSummary {\n  Long getId();\n  String getName();\n  MarketStatus getStatus();\n}\nPage\u003CMarketSummary> findAllBy(Pageable pageable);\n```\n\n## Transactions\n\n- Annotate service methods with `@Transactional`\n- Use `@Transactional(readOnly = true)` for read paths to optimize\n- Choose propagation carefully; avoid long-running transactions\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## Pagination\n\n```java\nPageRequest page = PageRequest.of(pageNumber, pageSize, Sort.by(\"createdAt\").descending());\nPage\u003CMarketEntity> markets = repo.findByStatus(MarketStatus.ACTIVE, page);\n```\n\nFor cursor-like pagination, include `id > :lastId` in JPQL with ordering.\n\n## Indexing and Performance\n\n- Add indexes for common filters (`status`, `slug`, foreign keys)\n- Use composite indexes matching query patterns (`status, created_at`)\n- Avoid `select *`; project only needed columns\n- Batch writes with `saveAll` and `hibernate.jdbc.batch_size`\n\n## Connection Pooling (HikariCP)\n\nRecommended properties:\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\nFor PostgreSQL LOB handling, add:\n```\nspring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true\n```\n\n## Caching\n\n- 1st-level cache is per EntityManager; avoid keeping entities across transactions\n- For read-heavy entities, consider second-level cache cautiously; validate eviction strategy\n\n## Migrations\n\n- Use Flyway or Liquibase; never rely on Hibernate auto DDL in production\n- Keep migrations idempotent and additive; avoid dropping columns without plan\n\n## Testing Data Access\n\n- Prefer `@DataJpaTest` with Testcontainers to mirror production\n- Assert SQL efficiency using logs: set `logging.level.org.hibernate.SQL=DEBUG` and `logging.level.org.hibernate.orm.jdbc.bind=TRACE` for parameter values\n\n**Remember**: Keep entities lean, queries intentional, and transactions short. Prevent N+1 with fetch strategies and projections, and index for your read\u002Fwrite paths.\n",{"name":5,"origin":47,"description":7},"ECC","main","b0f0a87593c578a7898eccaf1b363f7f87c1f99b","plugins\u002FColin4k1024\u002Ftsp\u002Fskills\u002Fjpa-patterns",491,"https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins","https:\u002F\u002Fhol.org\u002Fplugins\u002Fbest-codex-plugins","https:\u002F\u002Fgithub.com\u002Fhashgraph-online","https:\u002F\u002Fhol.org","Open-source standards and developer tools for interoperable AI agents: discovery, identity, communication, payments, privacy and security.","2026-11-14 14:06:13",{"source":8,"skillName":5,"commands":59,"prompt":69,"zipAvailable":70},[60,63,66],{"tool":61,"command":62},"npx","npx skills add hashgraph-online\u002Fawesome-codex-plugins --skill jpa-patterns",{"tool":64,"command":65},"bunx","bunx skills add hashgraph-online\u002Fawesome-codex-plugins --skill jpa-patterns",{"tool":67,"command":68},"pnpm","pnpm dlx skills add hashgraph-online\u002Fawesome-codex-plugins --skill jpa-patterns","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002FColin4k1024\u002Ftsp\u002Fskills\u002Fjpa-patterns\u002FSKILL.md",true,[],[73,83,91,99,107,115],{"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":77,"licenseFileUrl":78,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":82},"01M7DV332YQMGD8WTRJ9DZQXTB","worktable-review-with-annotations","Create, inspect, reply to, update, or resolve situated Worktable annotations. Use when feedback belongs to a Doc section, block, text range, or HTML Doc, or when the user asks to address existing review feedback and coordinate a requested artifact edit.","MIT","https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Fworktable\u002Fworktable-plugin\u002Fskills\u002Fworktable-review-with-annotations\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Fworktable\u002Fworktable-plugin\u002Fskills\u002Fworktable-review-with-annotations\u002FSKILL.md",[],[],"2026-11-15 14:19:17",{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":77,"licenseFileUrl":87,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":82},"01M7DV2YGHCZVBEB1AHYB6CGHE","worktable-find-and-synthesize-context","Find, assess, and synthesize context from Worktable Docs and Records. Use when the user asks what a workspace contains, wants workspace-backed research, needs current facts reconciled across artifacts, or requests a cited synthesis without changing workspace state.","https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Fworktable\u002Fworktable-plugin\u002Fskills\u002Fworktable-find-and-synthesize-context\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Fworktable\u002Fworktable-plugin\u002Fskills\u002Fworktable-find-and-synthesize-context\u002FSKILL.md",[],[],{"skillNo":92,"name":93,"nameZh":6,"description":94,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":77,"licenseFileUrl":95,"sourceHtmlUrl":96,"categories":97,"keywords":98,"publishedAt":82},"01M7DV2TQN1H11ME2SAF9MXN7V","worktable-create-or-update-docs","Create, edit, rename, or maintain narrative Worktable Docs. Use for plans, decisions, briefs, notes, research syntheses, and other durable prose when the user requests a new artifact or a safe update to an existing one.","https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Fworktable\u002Fworktable-plugin\u002Fskills\u002Fworktable-create-or-update-docs\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Fworktable\u002Fworktable-plugin\u002Fskills\u002Fworktable-create-or-update-docs\u002FSKILL.md",[],[],{"skillNo":100,"name":101,"nameZh":6,"description":102,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":77,"licenseFileUrl":103,"sourceHtmlUrl":104,"categories":105,"keywords":106,"publishedAt":82},"01M7DV2NE452NEA8TXATKSNAJH","worktable-create-or-manage-records","Organize repeated structured information as durable Worktable Records. Use for research datasets, inventories, directories, pipelines, trackers, and other collections whose items need identity, fields, filtering, links, validation, or individual updates.","https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Fworktable\u002Fworktable-plugin\u002Fskills\u002Fworktable-create-or-manage-records\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Fworktable\u002Fworktable-plugin\u002Fskills\u002Fworktable-create-or-manage-records\u002FSKILL.md",[],[],{"skillNo":108,"name":109,"nameZh":6,"description":110,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":77,"licenseFileUrl":111,"sourceHtmlUrl":112,"categories":113,"keywords":114,"publishedAt":82},"01M7DV2HENRBR2KSCVM064WH0Y","worktable-create-or-manage-interactive-html","Create or improve durable visual and interactive artifacts in Worktable. Use for dashboards, trackers, calculators, mini apps, slide presentations, and other requests that benefit from a polished HTML Doc.","https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Fworktable\u002Fworktable-plugin\u002Fskills\u002Fworktable-create-or-manage-interactive-html\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Fworktable\u002Fworktable-plugin\u002Fskills\u002Fworktable-create-or-manage-interactive-html\u002FSKILL.md",[],[],{"skillNo":116,"name":117,"nameZh":6,"description":118,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":77,"licenseFileUrl":119,"sourceHtmlUrl":120,"categories":121,"keywords":122,"publishedAt":82},"01M7DV2CADR5R7RQFFYPNAGR9Y","worktable-collaborate-threads","Read, answer, and hand off messages through durable Worktable threads with users or other authenticated participants. Use when the user asks to check addressed messages, reply to a participant, continue a thread, request another agent's help, wait briefly for a response, or watch for comments and messages sent to the agent.","https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Fworktable\u002Fworktable-plugin\u002Fskills\u002Fworktable-collaborate-threads\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Fworktable\u002Fworktable-plugin\u002Fskills\u002Fworktable-collaborate-threads\u002FSKILL.md",[],[]]