# Hibernate 8 + Jakarta Persistence 4: EntityAgent demo Runnable companion to the ankurm.com article on `EntityAgent` and stateless sessions. Every number in the article comes from a file in [`output/`](output), and each of those files is written by a test that asserts the same numbers, so a figure that stops being true fails the build. ## Versions tested | Component | Version | |---|---| | Hibernate ORM | 8.0.0.CR1 (release candidate, 12 Nov 2026) | | Jakarta Persistence API | 4.0.0-M8 (milestone, resolved transitively by CR1) | | JDK | Temurin 25.0.5+8 | | H2 | 2.5.252 | | HSQLDB (test scope, comparison runs) | 2.7.4 | | JUnit | 6.1.3 | | Maven | 3.9.11 | Hibernate 8 and Jakarta Persistence 4 are pre-release. Assertions in `Demo05Test` and `Demo09Test` are deliberately pinned to CR1 behaviour, so they fail when a later build changes it. ## Run it ./scripts/run-all.sh ## Layout | Path | What it shows | |---|---| | `src/main/java/com/ankurm/agent/` | `Book`, `Publisher`, `Setting` entities and the `BookSummary` record | | `src/test/java/com/ankurm/agent/Lab.java` | boots a SessionFactory and records every prepared SQL statement | | `Demo01Test` | same edit through `EntityManager` and `EntityAgent` | | `Demo02Test` | `get()` vs `find()`, no first-level cache, `getMultiple()` | | `Demo03Test` | lazy associations and `fetch()` | | `Demo04Test` | bulk insert: persistence-context size and statements prepared | | `Demo05Test` | lock modes on a stateless handler, H2 and HSQLDB | | `Demo06Test` | `@ExcludedFromVersioning` | | `Demo07Test` | programmatic result set mappings | | `Demo08Test` | `upsert()`, `delete()`, duplicate-key exception | | `Demo09Test` | the same operations on H2 and HSQLDB | ## Captured output `output/01-entitymanager-vs-entityagent.txt`, `02-get-find-and-no-cache`, `03-lazy-associations-and-fetch`, `04-bulk-insert`, `05-lock-modes-in-entityagent`, `06-excluded-from-versioning`, `07-programmatic-result-set-mapping`, `08-upsert-delete-and-errors`, `09-same-operations-two-databases`.