java-hibernate-jpa
Installation
SKILL.md
Hibernate ORM and Jakarta Persistence
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.
First: detect the stack
- Read
pom.xml/build.gradle(or the dependency tree) forhibernate-coreand the persistence API:jakarta.persistence(Hibernate 6+/Jakarta EE 9+) vsjavax.persistence(Hibernate 5, seejavax-to-jakarta-migration). - Note the Hibernate major version; behavior differs (see
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+. - Note the database and whether the schema is managed by Flyway/Liquibase.
- Turn on SQL logging and statistics in a test (see
references/tooling-and-versions.md) before "optimizing" anything: measure statement counts.