- I run the SchemaTool against each individual schema in the Oracle db and all works except 2 schema, OM and PM, There are total of 37 schema in the database.
- The problems exhibited for these 2 schema looks like below which is different from the NPE. At least it posted a meaningful message.
4641 TRACE [main] openjpa.jdbc.JDBC - <t 1183336072, conn 1139688430> [0 ms] close
Exception in thread "main" java.lang.RuntimeException: java.sql.SQLException: Table "OE.CUSTOMERS" has a foreign key to table "HR.EMPLOYEES"
that has not been generated. You must run the schema generator on all inter-related tables at once.
Caused by: java.sql.SQLException: Table "OE.CUSTOMERS" has a foreign key to table "HR.EMPLOYEES" that has not been generated. You must run
the schema generator on all inter-related tables at once.
I re-run and debug the schemaTool against all the schema and I was able to reproduce the exception (NPE) condition. The table that is in question is OE.PURCHASERS.
- Then I generated the DDL for the OE schema and I found that
CREATE TABLE OE.PURCHASEORDERS (
ALTER TABLE OE.PURCHASEORDERS ADD CONSTRAINT USER_IS_VALID FOREIGN KEY (null)
REFERENCES HR.EMPLOYEES (EMPLOYEE_ID)
ON DELETE RESTRICT
ON UPDATE CASCADE;
- Notice the funny "SYS_NC_ROWINFO$ null" column definition in OE.PURCHASEORDERS and null in the FOREIGN KEY constraint definition.
- I try to re-create the table using the same syntax and was rejected by the db.
I believe this table is abnormal and was create/modified in some ways that I don't know how it gets to this configuration.
To improve serviceability, a null check of of the fk table column and a more meaningful would be appropriate.