[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7CRKGDFB5AMY9EESX5ZT5KV":3,"skill-same:01M7CRKGDFB5AMY9EESX5ZT5KV":49},{"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":26,"commitSha":27,"skillDirectory":28,"forksCount":29,"repositoryHtmlUrl":30,"repositoryHomepageUrl":31,"ownerHtmlUrl":32,"ownerBlogUrl":6,"ownerDescription":33,"updatedAt":34,"install":35,"resources":48},"01M7CRKGDFB5AMY9EESX5ZT5KV","java-persistence",null,"Use when a Java service reads or writes the database - JPA\u002FHibernate and Panache\u002FSpring Data mapping, transaction boundaries, pagination and avoiding N+1 and entity-over-the-wire leaks","makifbaysal\u002Ftasktrooper","makifbaysal","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F25031940?v=4","01M7CRG3ZCSYZSSEVDMW3DEYC8","Mehmet Akif Baysal","01M7CRG401FJ8YAXH5ER730XYV",122,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fmakifbaysal\u002Ftasktrooper\u002Fblob\u002Fmain\u002Fcatalog\u002Fagents\u002Fbackend-developer\u002Fskills\u002Fjava-persistence\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: java-persistence\ncategory: architecture\ndescription: Use when a Java service reads or writes the database - JPA\u002FHibernate and Panache\u002FSpring Data mapping, transaction boundaries, pagination and avoiding N+1 and entity-over-the-wire leaks\ntech_stack: Java\n---\n# Java Persistence (JPA \u002F Panache \u002F Spring Data)\n\n## Overview\n\nPersistence is where Java services most often leak — lazy-loading exceptions, N+1 queries, entities serialized over HTTP, pagination applied in memory. Keep persistence at the repository boundary and mapped deliberately.\n\n**Core principle:** Entities are a persistence detail. They never cross the HTTP boundary and they never carry business logic that belongs in the domain. Every list query is bounded AND the bound is honored by the SQL, not by Java code truncating a full result set.\n\n## Mapping surface\n\n| Concern | Quarkus (Panache) | Spring Data |\n|---------|-------------------|-------------|\n| Entity | `@Entity` + `PanacheEntityBase` or plain `@Entity` | `@Entity` |\n| Repository | `implements PanacheRepository\u003CTask>` | `extends JpaRepository\u003CTask, UUID>` |\n| Query | `find(\"status\", s)` \u002F HQL | derived methods \u002F `@Query` |\n| Transaction | `@Transactional` on the service | `@Transactional` on the service |\n| Pagination | `.page(Page.of(n, size))` | `Pageable` \u002F `Page\u003CT>` |\n| Optimistic lock | `@Version` | `@Version` |\n| Schema management (non-test) | `quarkus.hibernate-orm.schema-management.strategy=none` (or `validate`; property renamed from `database.generation` in 3.23) | `spring.jpa.hibernate.ddl-auto=validate` |\n\n## Rules\n\n- **Transaction boundary = the service method**, never the repository or the resource. One use-case = one transaction.\n- **Never return entities from a controller\u002Fresource.** Map to a DTO inside the service (or a JPA projection). Returning entities causes lazy-init serialization errors and leaks the schema.\n- **Fetch deliberately to avoid N+1.** A loop that touches a lazy collection per row issues a query per row. Use a `JOIN FETCH` \u002F entity graph \u002F `@BatchSize` or `hibernate.default_batch_fetch_size`, and verify with a query-count assertion in a test.\n- **Never paginate a collection `JOIN FETCH`.** Hibernate applies `LIMIT`\u002F`OFFSET` in memory when the query also fetches a `*-to-many` collection (warning `HHH90003004`) — it loads the whole table to paginate it. Set `hibernate.query.fail_on_pagination_over_collection_fetch=true` in the test profile so this fails loudly instead of shipping slow. Page the root entity's ids first (plain query, no fetch join), then fetch the page by id with the collection join, or rely on `@BatchSize`\u002F`hibernate.default_batch_fetch_size` instead of a fetch join at all.\n- **Bound every list query.** Page (`Page`\u002F`Pageable`, Panache `.page(...)`) — never `findAll()`\u002F`listAll()` on a growing table. Default and maximum page size live with the endpoint (api-design-conventions), not just the repository call.\n- **Migrations own the schema, not `hibernate.hbm2ddl=update`\u002FQuarkus `generate-schema`.** Set validate\u002Fnone in non-test envs; schema changes go through a migration (postgres-migrations), never auto-DDL in production.\n- **Optimistic locking (`@Version`)** on entities with concurrent updates; map `OptimisticLockException`\u002F`ObjectOptimisticLockingFailureException` to 409 in the central error mapper (api-design-conventions), never let it surface as 500.\n- `spring.jpa.open-in-view=false` (Spring) — Open Session In View hides N+1s in the view layer and that lazy access outside a clear transaction boundary is exactly the mistake this skill exists to prevent.\n\n## Worked Example — killing an N+1 without breaking pagination\n\n```java\n\u002F\u002F ❌ N+1: one query for projects, then one per project for its tasks\nList\u003CProject> projects = repo.findAll(pageable).getContent();\nprojects.forEach(p -> total += p.getTasks().size());   \u002F\u002F lazy hit per row\n\n\u002F\u002F ❌ \"fixed\" with a fetch join but now unbounded: Hibernate pages in memory\n@Query(\"select p from Project p left join fetch p.tasks\")\nPage\u003CProject> findAllWithTasks(Pageable pageable);   \u002F\u002F HHH90003004\n\n\u002F\u002F ✅ page the roots first (no collection fetch), then fetch by id with the join\nPage\u003CUUID> ids = repo.findIds(pageable);\nList\u003CProject> page = repo.findByIdInWithTasks(ids.getContent());\n```\n\nAdd a query-count assertion (Hibernate `Statistics`, see java-testing-junit-mockito) so the N+1 can't creep back in, and a test on the test profile with `hibernate.query.fail_on_pagination_over_collection_fetch=true` so an accidental collection-fetch-plus-page regresses loudly instead of just getting slow.\n\n## Common Mistakes\n\n- `@Transactional` on the repository or resource instead of the service.\n- Serializing entities in the HTTP response.\n- `findAll()`\u002F`listAll()` with no paging.\n- Paginating a query that also does a collection `JOIN FETCH`.\n- `hbm2ddl=update` \u002F Quarkus schema generation in a real environment instead of migrations.\n- Testing on H2 where the SQL dialect differs from Postgres (java-testing-junit-mockito: use Testcontainers).\n- Letting `OptimisticLockException` surface as an unmapped 500.\n\n## Red Flags\n\n- `LazyInitializationException` in an HTTP response → you serialized an entity outside the transaction.\n- Query count scales with row count → N+1.\n- `HHH90003004` in the logs, or a pagination query that also lists `fetch` in its JPQL.\n- Schema changes with no migration file in the diff.\n","# Java Persistence (JPA \u002F Panache \u002F Spring Data)\n\n## Overview\n\nPersistence is where Java services most often leak — lazy-loading exceptions, N+1 queries, entities serialized over HTTP, pagination applied in memory. Keep persistence at the repository boundary and mapped deliberately.\n\n**Core principle:** Entities are a persistence detail. They never cross the HTTP boundary and they never carry business logic that belongs in the domain. Every list query is bounded AND the bound is honored by the SQL, not by Java code truncating a full result set.\n\n## Mapping surface\n\n| Concern | Quarkus (Panache) | Spring Data |\n|---------|-------------------|-------------|\n| Entity | `@Entity` + `PanacheEntityBase` or plain `@Entity` | `@Entity` |\n| Repository | `implements PanacheRepository\u003CTask>` | `extends JpaRepository\u003CTask, UUID>` |\n| Query | `find(\"status\", s)` \u002F HQL | derived methods \u002F `@Query` |\n| Transaction | `@Transactional` on the service | `@Transactional` on the service |\n| Pagination | `.page(Page.of(n, size))` | `Pageable` \u002F `Page\u003CT>` |\n| Optimistic lock | `@Version` | `@Version` |\n| Schema management (non-test) | `quarkus.hibernate-orm.schema-management.strategy=none` (or `validate`; property renamed from `database.generation` in 3.23) | `spring.jpa.hibernate.ddl-auto=validate` |\n\n## Rules\n\n- **Transaction boundary = the service method**, never the repository or the resource. One use-case = one transaction.\n- **Never return entities from a controller\u002Fresource.** Map to a DTO inside the service (or a JPA projection). Returning entities causes lazy-init serialization errors and leaks the schema.\n- **Fetch deliberately to avoid N+1.** A loop that touches a lazy collection per row issues a query per row. Use a `JOIN FETCH` \u002F entity graph \u002F `@BatchSize` or `hibernate.default_batch_fetch_size`, and verify with a query-count assertion in a test.\n- **Never paginate a collection `JOIN FETCH`.** Hibernate applies `LIMIT`\u002F`OFFSET` in memory when the query also fetches a `*-to-many` collection (warning `HHH90003004`) — it loads the whole table to paginate it. Set `hibernate.query.fail_on_pagination_over_collection_fetch=true` in the test profile so this fails loudly instead of shipping slow. Page the root entity's ids first (plain query, no fetch join), then fetch the page by id with the collection join, or rely on `@BatchSize`\u002F`hibernate.default_batch_fetch_size` instead of a fetch join at all.\n- **Bound every list query.** Page (`Page`\u002F`Pageable`, Panache `.page(...)`) — never `findAll()`\u002F`listAll()` on a growing table. Default and maximum page size live with the endpoint (api-design-conventions), not just the repository call.\n- **Migrations own the schema, not `hibernate.hbm2ddl=update`\u002FQuarkus `generate-schema`.** Set validate\u002Fnone in non-test envs; schema changes go through a migration (postgres-migrations), never auto-DDL in production.\n- **Optimistic locking (`@Version`)** on entities with concurrent updates; map `OptimisticLockException`\u002F`ObjectOptimisticLockingFailureException` to 409 in the central error mapper (api-design-conventions), never let it surface as 500.\n- `spring.jpa.open-in-view=false` (Spring) — Open Session In View hides N+1s in the view layer and that lazy access outside a clear transaction boundary is exactly the mistake this skill exists to prevent.\n\n## Worked Example — killing an N+1 without breaking pagination\n\n```java\n\u002F\u002F ❌ N+1: one query for projects, then one per project for its tasks\nList\u003CProject> projects = repo.findAll(pageable).getContent();\nprojects.forEach(p -> total += p.getTasks().size());   \u002F\u002F lazy hit per row\n\n\u002F\u002F ❌ \"fixed\" with a fetch join but now unbounded: Hibernate pages in memory\n@Query(\"select p from Project p left join fetch p.tasks\")\nPage\u003CProject> findAllWithTasks(Pageable pageable);   \u002F\u002F HHH90003004\n\n\u002F\u002F ✅ page the roots first (no collection fetch), then fetch by id with the join\nPage\u003CUUID> ids = repo.findIds(pageable);\nList\u003CProject> page = repo.findByIdInWithTasks(ids.getContent());\n```\n\nAdd a query-count assertion (Hibernate `Statistics`, see java-testing-junit-mockito) so the N+1 can't creep back in, and a test on the test profile with `hibernate.query.fail_on_pagination_over_collection_fetch=true` so an accidental collection-fetch-plus-page regresses loudly instead of just getting slow.\n\n## Common Mistakes\n\n- `@Transactional` on the repository or resource instead of the service.\n- Serializing entities in the HTTP response.\n- `findAll()`\u002F`listAll()` with no paging.\n- Paginating a query that also does a collection `JOIN FETCH`.\n- `hbm2ddl=update` \u002F Quarkus schema generation in a real environment instead of migrations.\n- Testing on H2 where the SQL dialect differs from Postgres (java-testing-junit-mockito: use Testcontainers).\n- Letting `OptimisticLockException` surface as an unmapped 500.\n\n## Red Flags\n\n- `LazyInitializationException` in an HTTP response → you serialized an entity outside the transaction.\n- Query count scales with row count → N+1.\n- `HHH90003004` in the logs, or a pagination query that also lists `fetch` in its JPQL.\n- Schema changes with no migration file in the diff.\n",{"name":5,"category":24,"tech_stack":25,"description":7},"architecture","Java","main","910394a0b6db9fc8c9a8f36328ec421d3ebd8b38","catalog\u002Fagents\u002Fbackend-developer\u002Fskills\u002Fjava-persistence",18,"https:\u002F\u002Fgithub.com\u002Fmakifbaysal\u002Ftasktrooper","https:\u002F\u002Ftasktrooper.ai","https:\u002F\u002Fgithub.com\u002Fmakifbaysal","Senior Software Developer","2026-11-15 04:50:29",{"source":8,"skillName":5,"commands":36,"prompt":46,"zipAvailable":47},[37,40,43],{"tool":38,"command":39},"npx","npx skills add makifbaysal\u002Ftasktrooper --skill java-persistence",{"tool":41,"command":42},"bunx","bunx skills add makifbaysal\u002Ftasktrooper --skill java-persistence",{"tool":44,"command":45},"pnpm","pnpm dlx skills add makifbaysal\u002Ftasktrooper --skill java-persistence","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fmakifbaysal\u002Ftasktrooper\u002Fblob\u002Fmain\u002Fcatalog\u002Fagents\u002Fbackend-developer\u002Fskills\u002Fjava-persistence\u002FSKILL.md",true,[],[50,56,63,70,77,84],{"skillNo":51,"name":52,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":53,"categories":54,"keywords":55,"publishedAt":19},"01M7CSVEPQW6J6TD6CS2T5FPNZ","visual-craft","https:\u002F\u002Fgithub.com\u002Fmakifbaysal\u002Ftasktrooper\u002Fblob\u002Fmain\u002Fcatalog\u002Fagents\u002Fui-designer\u002Fskills\u002Fvisual-craft\u002FSKILL.md",[],[],{"skillNo":57,"name":58,"nameZh":6,"description":59,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":60,"categories":61,"keywords":62,"publishedAt":19},"01M7CSVAQG91ETHQ0HBNZDG5FR","ux-copy","Use when you write any words a user reads in a mockup or a hand-off - content language and voice, buttons, labels, errors, empty states, confirmations, numbers and dates, and the longest-string check","https:\u002F\u002Fgithub.com\u002Fmakifbaysal\u002Ftasktrooper\u002Fblob\u002Fmain\u002Fcatalog\u002Fagents\u002Fui-designer\u002Fskills\u002Fux-copy\u002FSKILL.md",[],[],{"skillNo":64,"name":65,"nameZh":6,"description":66,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":67,"categories":68,"keywords":69,"publishedAt":19},"01M7CSV6H0J38659NDXHJQ8396","screen-mockup-html","Use when you draw screens as the design task's HTML mockup - ONE canvas document holding every screen and every variant side by side, the sanitizer-safe recipe, phone and wide frames, the states grid, static control states, and the loopback self-check with screenshots at 375, 768 and 1440 attached to the task","https:\u002F\u002Fgithub.com\u002Fmakifbaysal\u002Ftasktrooper\u002Fblob\u002Fmain\u002Fcatalog\u002Fagents\u002Fui-designer\u002Fskills\u002Fscreen-mockup-html\u002FSKILL.md",[],[],{"skillNo":71,"name":72,"nameZh":6,"description":73,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":74,"categories":75,"keywords":76,"publishedAt":19},"01M7CSV3JFRF3BM3XK52M7YEYR","performance-awareness","How the performance score moves for your role. Use when the score context shows a declining trend, or before handing off work you have not self-checked against every criterion.","https:\u002F\u002Fgithub.com\u002Fmakifbaysal\u002Ftasktrooper\u002Fblob\u002Fmain\u002Fcatalog\u002Fagents\u002Fui-designer\u002Fskills\u002Fperformance-awareness\u002FSKILL.md",[],[],{"skillNo":78,"name":79,"nameZh":6,"description":80,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":19},"01M7CSTZDH00YRF5SCT7BRT9QD","design-variants","Use when a screen design needs variants - how many, variants as side-by-side rows on the one canvas, what makes two variants genuinely different, recommending one, how the human's choice is read, and narrowing to the chosen one in revision","https:\u002F\u002Fgithub.com\u002Fmakifbaysal\u002Ftasktrooper\u002Fblob\u002Fmain\u002Fcatalog\u002Fagents\u002Fui-designer\u002Fskills\u002Fdesign-variants\u002FSKILL.md",[],[],{"skillNo":85,"name":86,"nameZh":6,"description":87,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":19},"01M7CSTV6P3SM3PAE28DB0RF77","design-system-authoring","Use when you derive, change or extend a design system - where tokens live per stack, the DTCG token tree, role-based names for both themes, base vs layer vs drift, the DESIGN.md section order, the inventory format, the contrast check and the lint every proposal returns","https:\u002F\u002Fgithub.com\u002Fmakifbaysal\u002Ftasktrooper\u002Fblob\u002Fmain\u002Fcatalog\u002Fagents\u002Fui-designer\u002Fskills\u002Fdesign-system-authoring\u002FSKILL.md",[],[]]