Files
hibernate-demo/json-columns/FINDINGS.md
T

26 lines
2.5 KiB
Markdown

# json-columns findings (Hibernate 7.4.14.Final, PostgreSQL 18.6, MySQL 8.0.46)
Learned by running the module tests (output/NN-*.txt are the evidence).
- PostgreSQL: SqlTypes.JSON emits `jsonb` (A01). `@JdbcType(PostgreSQLJsonPGObjectJsonType)` still emits jsonb DDL; use columnDefinition = "json" to get json.
- Jackson choice: Jackson 3 only -> Jackson3JsonFormatMapper; both present -> Jackson 2 JacksonJsonFormatMapper wins silently (fails on Instant without jsr310); none -> startup HibernateException. `hibernate.type.json_format_mapper=jackson|jackson3|jsonb|instance` (A09, output/09).
- Jackson 3 mapper as configured by Hibernate FAILS on unknown properties; missing keys default silently.
- HQL json_value/json_query/json_exists/json_object/json_table/aggregates need `hibernate.query.hql.json_functions_enabled=true`; json_set in UPDATE ran without it (only modifier tried) (A04).
- Native `?` operator: only `\?\?` works; use jsonb_exists() or `@>`; `:p::jsonb` fails, use cast(:p as jsonb) (A06).
- Dirty checking: in-place Map/List/POJO/record changes detected (snapshot = serialise+parse, Objects.equals); POJO without equals() => UPDATE on every flush; BigDecimal in Map => UPDATE right after INSERT; all columns rewritten unless @DynamicUpdate (A03, output/12).
- Indexing, 50,000 rows: Q1 @> 10.2 ms seq scan -> 0.68 ms GIN -> 0.18 ms jsonb_path_ops; Q4 20.1 -> ~2.9 ms; path_ops cannot serve `?`; only a b-tree on the exact expression serves `->>` equality (A07, output/07). MySQL: functional and multi-valued indexes needed the exact expression (A08).
- hypersistence-utils: @TypeDef/@Type(type=) absent in 7.4.14; com.vladmihalcea hibernate-types-60 last 2.21.1 (2022-12); hypersistence-utils-hibernate-73 3.16.0 (2026-09-20) JsonType works on 7.4.14 (A10, output/13).
- Spring: HibernatePropertiesCustomizer lives in org.springframework.boot.hibernate.autoconfigure (Boot 4); Boot JsonMapper is not Hibernate's by default.
## Sandbox notes
Zonky embedded PostgreSQL 18.6 binaries from Maven Central (Central 429s: retry); MySQL via apt. /dev/null was a regular file (chmod 666). org.hibernate.tool.hbm2ddl.SchemaExport not in hibernate-core 7 (use JPA script generation).
## Not tested
MariaDB, Oracle, SQL Server, DB2, HANA, H2 JSON; jsonb format mapper (Yasson); SqlTypes.JSON_ARRAY; TOAST; GIN write cost; json (not jsonb) query behaviour; PG < 18.
## Incidental defects
None in existing modules observed beyond what is listed above.
## Publishing
Post ID, permalink and commit sha: see final report.