Skip to content

test(jdbc): add Hibernate integration smoke tests - #264

Merged
magnusp merged 4 commits into
mainfrom
test/hibernate-itests
Oct 30, 2026
Merged

magnusp merged 4 commits into
mainfrom
test/hibernate-itests

Conversation

@magnusp

@magnusp magnusp commented Oct 30, 2026

Copy link
Copy Markdown
Owner

Summary

Promotes the Hibernate smoke prototype into libsql-jdbc as a Failsafe integration test.

  • HibernateIT drives the in-tree driver through Hibernate ORM 7.4: identity-generated keys, scalar mapping, @ManyToOne associations, HQL joins and pagination, repeated inserts, schema validation, and optimistic locking.
  • HibernateSqldSupport starts the pinned sqld Testcontainer and creates the schema through JDBC. Hibernate 7.4's SQLite dialect emits an untyped identity column for book, so its own DDL is not used; the validator test still reads the schema back through the driver's DatabaseMetaData.
  • Optimistic locking coverage:
    • version increment on a successful update;
    • explicit OPTIMISTIC_FORCE_INCREMENT;
    • stale detached merge;
    • stale delete;
    • versioned update through a foreign-key association;
    • timestamp-valued @Version round-trip and stale merge.
  • Stale-write tests assert Hibernate receives an update count of 0, throws an optimistic-lock exception, and leaves the stored row unchanged.
  • Test-only dependencies: Hibernate 7.4.13, Testcontainers, and Failsafe *IT wiring. ./mvnw test stays unit-only.
  • The module copies the shared Docker config into target/docker-config and sets DOCKER_CONFIG for Failsafe, so sandboxed runs work without a shell override.

Driver findings

No driver-level defects surfaced in the covered Hibernate paths. Generated keys, versioned update/delete counts, timestamp comparisons, and schema validation all behaved correctly.

Auto-commit identity

#83 already tracks the relevant limitation: in auto-commit, a direct SELECT last_insert_rowid() reads a fresh Hrana stream. Hibernate's GenerationType.IDENTITY uses that same query, so this suite keeps auto-commit disabled (Hibernate's default) and documents the dependency. No duplicate issue was created.

Refs #83

Test plan

  • ./mvnw -pl libsql-jdbc -am -Dit.test=HibernateIT -Dtest=NoSuchTest -Dsurefire.failIfNoSpecifiedTests=false verify — 11 tests pass
  • ./mvnw spotless:check
  • ./prototype/hibernate-smoke/run.sh — 11 prototype tests pass against a throwaway sqld container

@magnusp
magnusp enabled auto-merge (squash) October 30, 2026 23:42
@magnusp
magnusp merged commit 4ad86d7 into main Oct 30, 2026
5 checks passed
@magnusp
magnusp deleted the test/hibernate-itests branch October 30, 2026 23:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant