扫描现有项目的代码与配置,生成涵盖技术栈、结构、架构、规范、集成、测试和风险的七份文档。为结论标注文件依据和未知项,并指出计划描述与实际实现的差异。
- 了解陌生代码库
- 准备项目交接文档
- 对照设计资料与实际实现
Review and fix Java database mappings and queries with Hibernate ORM and Jakarta Persistence. Diagnose excessive queries, delayed data loading errors, and update conflicts, then check entity design and database behavior using SQL measurements.
中文简介正在准备中。当前显示英语简介。
Diagnose and fix Hibernate ORM / Jakarta Persistence problems in plain Java: N+1 queries, lazy loading errors, identifier generation, entity equals/hashCode, cascades, pagination, batching, locking, caching, Lombok on entities, and Hibernate 6/7 differences. Use when reviewing or writing JPA entities, mappings, and queries. Framework-neutral.
实测评分 未实测
查看安装方法安装前可以查看交给 AI 代理的指令内容。
Problem -> anti-pattern -> fix library for entity mapping and querying. Framework-neutral: it covers EntityManager/Session behavior, JPQL/HQL, and mapping annotations. If the project uses Spring Boot and the java-springboot and spring-boot-testing skills are installed, use them for Spring Data repositories, transaction wiring, and @DataJpaTest; for Panache and reactive persistence see the Quarkus skills. Integration tests against a real database: java-testcontainers.
pom.xml/build.gradle (or the dependency tree) for hibernate-core and the persistence API: jakarta.persistence (Hibernate 6+/Jakarta EE 9+) vs javax.persistence (Hibernate 5, see javax-to-jakarta-migration).references/tooling-and-versions.md). Hibernate 6.0-6.1 implement Jakarta Persistence 3.0, 6.2+ implement 3.1, 7.x implements 3.2, and Hibernate 7 needs Java 17+.references/tooling-and-versions.md) before "optimizing" anything: measure statement counts.| Symptom | Likely cause | Go to |
|---|---|---|
| Many similar SELECTs for one request | N+1 on lazy association | references/fetching-and-n-plus-one.md |
LazyInitializationException | Lazy access outside session | references/fetching-and-n-plus-one.md |
HHH000104 / HHH90003004 warning, big memory use | Pagination with collection fetch join | references/queries-pagination-batching.md |
| Inserts slow, no JDBC batching | IDENTITY ids or batching not configured | references/identifiers-and-entity-design.md, references/queries-pagination-batching.md |
Duplicate rows / lost children / Set anomalies | Bad equals/hashCode or cascade misuse | references/identifiers-and-entity-design.md, references/associations-and-cascade.md |
| Lost updates, deadlocks | Missing locking strategy | references/locking-transactions-caching.md |
| Stale or surprising data with caches | Second-level/query cache misuse | references/locking-transactions-caching.md |
Schema drift, ddl-auto in prod | No migration tool | references/tooling-and-versions.md |
@ManyToOne/@OneToOne default to EAGER; declare fetch = FetchType.LAZY explicitly. @OneToMany/@ManyToMany are LAZY by default and should stay so. Choose fetching per query (JOIN FETCH, entity graph), not by making mappings EAGER.@ManyToOne owning side plus a bidirectional @OneToMany(mappedBy=...) only when needed; keep both sides in sync through helper methods.Set or List for collections? Use Set for @ManyToMany; a unidirectional @OneToMany with @JoinColumn or List without an order has costly update patterns.CascadeType.REMOVE/ALL on @ManyToOne or @ManyToMany. Use orphanRemoval only on a true parent-owned child collection.SEQUENCE (pooled optimizer, allocationSize matching the DB increment) for generated numeric ids; IDENTITY disables JDBC insert batching; use UUIDs (time-ordered preferred) when ids must be generated client-side.@Data/@EqualsAndHashCode/@ToString over associations; implement equals/hashCode deliberately.ORDER BY including a unique tiebreaker; never combine setMaxResults with a collection JOIN FETCH.This is the single rule other skills refer to by name:
hibernate.hbm2ddl.auto=update (or create-drop for throwaway tests) is acceptable.hibernate.hbm2ddl.auto=validate (or none). Add them when the user wants versioned migrations or the app is headed to production.none (or validate); do not add a migration tool.Check statement counts for N+1, explicit LAZY on to-one associations, sequence-based ids with matching allocationSize, and equals/hashCode stable across transient to persistent. Version-dependent details (Hibernate 5/6/7): references/tooling-and-versions.md.
references/fetching-and-n-plus-one.md: N+1 detection and fixes, lazy vs eager, LazyInitializationException, open-session-in-view, DTO projections.references/identifiers-and-entity-design.md: id generation, equals/hashCode, Lombok, records vs entities, enums and converters, value types.references/associations-and-cascade.md: bidirectional helpers, cascade, orphanRemoval, collection choice, @ManyToMany.references/queries-pagination-batching.md: pagination (offset, keyset, in-memory warning), bulk operations, JDBC batching, StatelessSession.references/locking-transactions-caching.md: optimistic/pessimistic locking, transaction boundaries, flush modes, second-level cache.references/tooling-and-versions.md: SQL logging, statistics, tests, connection pool sizing, migrations, Hibernate 5/6/7 differences.Canonical docs: Hibernate ORM user guide https://docs.hibernate.org/orm/current/userguide/html_single/ and Jakarta Persistence https://jakarta.ee/specifications/persistence/. Deep background articles: https://vladmihalcea.com/.
Upgrading (fetch the page for the target version; prefer it over this skill): migration guides https://hibernate.org/orm/documentation/migrate/ (6.6: https://docs.hibernate.org/orm/6.6/migration-guide/, 7.0: https://docs.hibernate.org/orm/7.0/migration-guide/), release notes https://hibernate.org/orm/releases/.
还没有评价。欢迎分享你的使用感受。
无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。
还没有评论。来写第一条吧。
扫描现有项目的代码与配置,生成涵盖技术栈、结构、架构、规范、集成、测试和风险的七份文档。为结论标注文件依据和未知项,并指出计划描述与实际实现的差异。
使用AgentRC评估代码仓库对AI智能体的准备情况,并生成可独立打开的HTML报告。查看九个方面的评分和优先改进建议,也可按组织自定评分政策。
使用AgentRC分析项目代码中的语言、框架和开发惯例,生成或更新AI编程代理的指令文件。可集中写入一个文件,也可按主题和项目区域拆分,并在写入前预览改动。
按团队或组织标准调整AgentRC准备度评估。可选择或创建JSON策略,调整检查权重、停用无关检查、设置通过率,并在CI流程中设定自动检查门槛。
分析你提供的广告成效数据,找出浪费支出和表现较好的广告,并整理暂停、加预算或继续测试的候选项。还可比较不同平台、评估A/B测试差异,并提出预算调整建议。
为指定代码文件添加学习注释,解释语法、编程概念和设计选择;可按读者水平调整讲解深度和重复频率,并保持文件结构、编码与语法。