Class AuditTrailForeignKeyIntegrationTest

java.lang.Object
ubic.gemma.core.util.test.BaseTest5
ubic.gemma.core.util.test.BaseIntegrationTest5
ubic.gemma.persistence.hibernate.AuditTrailForeignKeyIntegrationTest

public class AuditTrailForeignKeyIntegrationTest extends BaseIntegrationTest5
AUDIT_TRAIL.LAST_EVENT_FK must be ON DELETE SET NULL in a schema Hibernate built.

Nothing in a JPA mapping can say this — HBM XML's <many-to-one on-delete> accepts only cascade or noaction, and JPA has no portable knob at all. The rule reached an hbm2ddl-built schema through two <database-object> elements in AuditTrail.hbm.xml, which was the last .hbm.xml in the repository and cost an HHH90000028 deprecation warning on every boot. It is now an AuxiliaryDatabaseObject registered from HibernateConfig, and this test is what says the move kept the behaviour.

🛑 Asserted against information_schema, not against the mapping. The failure this guards is a schema generated differently, so reading it back from the database is the only evidence that means anything — a test inspecting Hibernate's metadata would pass whether or not the DDL ever ran. Without the rule the constraint defaults to RESTRICT and deleting an AuditEvent a trail still points at fails with a ConstraintViolation, while the Flyway path (V8__audit_trail_last_event_id.sql) behaves correctly — the two schemas disagreeing, with only the built-from-scratch one wrong.

  • Constructor Details

    • AuditTrailForeignKeyIntegrationTest

      public AuditTrailForeignKeyIntegrationTest()
  • Method Details

    • testTheLastEventForeignKeyDeletesToNull

      @Test public void testTheLastEventForeignKeyDeletesToNull() throws Exception
      Plain JDBC rather than a Hibernate session: the schema is what is under test, so nothing here needs a persistence context, and reading it through one would only add a transaction to get wrong.
      Throws:
      Exception