Skip to content

SchemaManagerValidateOnMissingColumnTest.testValidateOnMissingColumn fails on DB2 #2596

@arjantijms

Description

@arjantijms

The following test fails on DB2:
org.eclipse.persistence.testing.tests.jpa.persistence32.SchemaManagerValidateOnMissingColumnTest.testValidateOnMissingColumn()

with

[ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 2.430 s <<< FAILURE! -- in org.eclipse.persistence.testing.tests.jpa.persistence32.SchemaManagerValidateOnMissingColumnTest
[ERROR] org.eclipse.persistence.testing.tests.jpa.persistence32.SchemaManagerValidateOnMissingColumnTest.testValidateOnMissingColumn -- Time elapsed: 2.408 s <<< FAILURE!
junit.framework.AssertionFailedError: Exception is not an instance of TableValidationException.MissingColumns
	at junit.framework.Assert.fail(Assert.java:57)
	at junit.framework.TestCase.fail(TestCase.java:223)
	at org.eclipse.persistence.testing.tests.jpa.persistence32.SchemaManagerValidateOnMissingColumnTest.testValidateOnMissingColumn(SchemaManagerValidateOnMissingColumnTest.java:89)

What happens is that the test removed a column from a table, and the table is then in REORG_PENDING state:

db2 => select * from PERSISTENCE32_TEAM

ID         
-----------
SQL0668N  Operation not allowed for reason code "7" on table 
"ROOTX.PERSISTENCE32_TEAM".  SQLSTATE=57007

and

db2 => SELECT TABSCHEMA, TABNAME, REORG_PENDING FROM SYSIBMADM.ADMINTABINFO WHERE TABSCHEMA = 'ROOTX' AND TABNAME = 'PERSISTENCE32_TEAM';

TABSCHEMA                                                                                                                        TABNAME                                                                                                                          REORG_PENDING
-------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------- -------------
ROOTX                                                                                                                            PERSISTENCE32_TEAM                                                                                                               Y            

  1 record(s) selected.

A straightforward solution is to call REORG on the table from within the test:

       if (emf.getDatabaseSession().getPlatform().isDB2()) {
            // After table modifications, DB2 needs a kind of secondary commit called a 'REORG'
            // to make the table available again.
            emf.getDatabaseSession()
               .priviledgedExecuteNonSelectingCall(
                   new SQLCall("CALL SYSPROC.ADMIN_CMD('REORG TABLE PERSISTENCE32_TEAM')"));
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions