[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M75EW36R86C4DSR1AA5DG4SD":3,"skill-same:01M75EW36R86C4DSR1AA5DG4SD":47},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":29,"ownerHtmlUrl":30,"ownerBlogUrl":31,"ownerDescription":6,"updatedAt":32,"install":33,"resources":46},"01M75EW36R86C4DSR1AA5DG4SD","jpa-patterns",null,"JPA\u002FHibernate patterns for entity design, relationships, query optimization, transactions, auditing, indexing, pagination, and pooling in Spring Boot.","agisota\u002Fold-one","agisota","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F121413592?v=4","01M75B4BRNT67EC1NDRT8QZEP2","01M75B4BS7QR9VP580MSCPTS3X",3,"MIT","https:\u002F\u002Fgithub.com\u002Fagisota\u002Fold-one\u002Fblob\u002Fmain\u002Fskills\u002Fjpa-patterns\u002FSKILL.md",[],[],"2026-11-12 13:55:43",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":23,"description":7},"ECC","main","f37de8f681f0c0ca0e0ebab6e5fddf764ca7553d","skills\u002Fjpa-patterns",1,"https:\u002F\u002Fgithub.com\u002Fagisota\u002Fold-one","https:\u002F\u002Fagisota.github.io\u002Fold-one\u002F","https:\u002F\u002Fgithub.com\u002Fagisota","pzd.world","2026-07-04 22:32:06",{"source":8,"skillName":5,"commands":34,"prompt":44,"zipAvailable":45},[35,38,41],{"tool":36,"command":37},"npx","npx skills add agisota\u002Fold-one --skill jpa-patterns",{"tool":39,"command":40},"bunx","bunx skills add agisota\u002Fold-one --skill jpa-patterns",{"tool":42,"command":43},"pnpm","pnpm dlx skills add agisota\u002Fold-one --skill jpa-patterns","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fagisota\u002Fold-one\u002Fblob\u002Fmain\u002Fskills\u002Fjpa-patterns\u002FSKILL.md",true,[],[48,55,62,71,78,85],{"skillNo":49,"name":50,"nameZh":6,"description":51,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":52,"categories":53,"keywords":54,"publishedAt":18},"01M75KRGZWQWE9JDBS6RX42NWV","zoom-out","Tell the agent to zoom out and give broader context or a higher-level perspective. Use when you're unfamiliar with a section of code or need to understand how it fits into the bigger picture.","https:\u002F\u002Fgithub.com\u002Fagisota\u002Fold-one\u002Fblob\u002Fmain\u002Fskills\u002Fzoom-out\u002FSKILL.md",[],[],{"skillNo":56,"name":57,"nameZh":6,"description":58,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":59,"categories":60,"keywords":61,"publishedAt":18},"01M75KRCZHKE0ZYAQFFYHS0YNP","zeroize-audit","Detects missing zeroization of sensitive data in source code and identifies zeroization removed by compiler optimizations, with assembly-level analysis, and control-flow verification. Use for auditing C\u002FC++\u002FRust code handling secrets, keys, passwords, or other sensitive data.","https:\u002F\u002Fgithub.com\u002Fagisota\u002Fold-one\u002Fblob\u002Fmain\u002Fskills\u002Fzeroize-audit\u002FSKILL.md",[],[],{"skillNo":63,"name":64,"nameZh":6,"description":65,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":66,"licenseFileUrl":67,"sourceHtmlUrl":68,"categories":69,"keywords":70,"publishedAt":18},"01M75KR94KYQ30DTE1P9WNDAE0","yeet","Use only when the user explicitly asks to stage, commit, push, and open a GitHub pull request in one flow using the GitHub CLI (`gh`).","Apache-2.0","https:\u002F\u002Fgithub.com\u002Fagisota\u002Fold-one\u002Fblob\u002Fmain\u002Fskills\u002Fyeet\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fagisota\u002Fold-one\u002Fblob\u002Fmain\u002Fskills\u002Fyeet\u002FSKILL.md",[],[],{"skillNo":72,"name":73,"nameZh":6,"description":74,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":75,"categories":76,"keywords":77,"publishedAt":18},"01M75KR3H13YJ9QHMD49818FA1","yara-rule-authoring","Guides authoring of high-quality YARA-X detection rules for malware identification. Use when writing, reviewing, or optimizing YARA rules. Covers naming conventions, string selection, performance optimization, migration from legacy YARA, and false positive reduction. Triggers on: YARA, YARA-X, malware detection, threat hunting, IOC, signature, crx module, dex module.","https:\u002F\u002Fgithub.com\u002Fagisota\u002Fold-one\u002Fblob\u002Fmain\u002Fskills\u002Fyara-rule-authoring\u002FSKILL.md",[],[],{"skillNo":79,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":18},"01M75KQMPY8A4Y8XTDD2DT0M9T","x-twitter-growth","X\u002FTwitter growth engine for building audience, crafting viral content, and analyzing engagement. Use when the user wants to grow on X\u002FTwitter, write tweets or threads, analyze their X profile, research competitors on X, plan a posting strategy, or optimize engagement. Complements social-content (generic multi-platform) with X-specific depth: algorithm mechanics, thread engineering, reply strategy, profile optimization, and competitive intelligence via web search.","https:\u002F\u002Fgithub.com\u002Fagisota\u002Fold-one\u002Fblob\u002Fmain\u002Fskills\u002Fx-twitter-growth\u002FSKILL.md",[],[],{"skillNo":86,"name":87,"nameZh":6,"description":88,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":89,"categories":90,"keywords":91,"publishedAt":18},"01M75KQHNZ0ANZNJGZY6M8MDAK","x-api","X\u002FTwitter API integration for posting tweets, threads, reading timelines, search, and analytics. Covers OAuth auth patterns, rate limits, and platform-native content posting. Use when the user wants to interact with X programmatically.","https:\u002F\u002Fgithub.com\u002Fagisota\u002Fold-one\u002Fblob\u002Fmain\u002Fskills\u002Fx-api\u002FSKILL.md",[],[]]