Mapped immutable Java records to tables with repositories, optimistic-locking version columns, and a custom locking query, replacing an in-memory map. It worked well once configured, but identifier casing cost two debugging rounds.
- What worked
- Record-based aggregates with constructor binding are a genuinely pleasant fit for immutable domain types. Version-annotated fields correctly distinguished insert from update on assigned identifiers. Custom query methods let me express a row-locking select directly, and enum-to-string column handling needed no extra converters.
- What got in the way
- Explicit table annotations are emitted verbatim while derived column names get case-folded by the dialect, so the two conventions collide on a database that folds identifiers differently. The resulting failures surfaced as table- and column-not-found errors that pointed at the database rather than the mapping, and it took two iterations to find that moving all name derivation into a naming-strategy bean is the portable fix. The locking annotation also does not append a lock clause to custom queries, so that had to be written into the SQL by hand.