openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Albert Lee (JIRA)" <j...@apache.org>
Subject [jira] Commented: (OPENJPA-761) SchemaTool failed with a NPE in ForeignKey.join
Date Tue, 04 Nov 2008 18:08:44 GMT

    [ https://issues.apache.org/jira/browse/OPENJPA-761?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12645028#action_12645028
] 

Albert Lee commented on OPENJPA-761:
------------------------------------

- 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.
        at org.apache.openjpa.lib.conf.Configurations.launchRunnable(Configurations.java:711)
        at org.apache.openjpa.lib.conf.Configurations.runAgainstAllAnchors(Configurations.java:693)
        at org.apache.openjpa.jdbc.schema.SchemaTool.main(SchemaTool.java:1343)
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.
        at org.apache.openjpa.jdbc.schema.SchemaGenerator.generateForeignKeys(SchemaGenerator.java:772)
        at org.apache.openjpa.jdbc.schema.SchemaGenerator.generateForeignKeys(SchemaGenerator.java:431)
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 (
		SYS_NC_ROWINFO$ null
	);

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.

Albert Lee.

> SchemaTool failed with a NPE in ForeignKey.join
> -----------------------------------------------
>
>                 Key: OPENJPA-761
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-761
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jdbc
>    Affects Versions: 1.0.4, 1.1.1, 1.2.1, 1.3.0, 2.0.0
>            Reporter: Albert Lee
>            Assignee: Albert Lee
>            Priority: Minor
>             Fix For: 1.3.0, 2.0.0
>
>
> A test used the SchemaTool to reflect "all" schema in a Oracle DB but run in a NPE as
observed below:
>      [exec] 131  INFO   [main] openjpa.jdbc.JDBC - Using dictionary class "com.ibm.ws.persistence.jdbc.sql.OracleDictionary".
>      [exec] 1127  INFO   [main] openjpa.Tool - Reflecting on schemas "all".  This process
may take some time.  Enable the org.apache.openjpa.jdbc.Schema logging category to see messages
about the collection of schema data.
>      [exec] Exception in thread "main" java.lang.NullPointerException
>      [exec] 	at org.apache.openjpa.jdbc.schema.ForeignKey.join(ForeignKey.java:521)
>      [exec] 	at org.apache.openjpa.jdbc.schema.SchemaGenerator.generateForeignKeys(SchemaGenerator.java:794)
>      [exec] 	at org.apache.openjpa.jdbc.schema.SchemaGenerator.generateForeignKeys(SchemaGenerator.java:431)
>      [exec] 	at org.apache.openjpa.jdbc.schema.SchemaGenerator.generateSchemas(SchemaGenerator.java:278)
>      [exec] 	at org.apache.openjpa.jdbc.schema.SchemaGenerator.generateSchemas(SchemaGenerator.java:243)
>      [exec] 	at org.apache.openjpa.jdbc.schema.SchemaTool.run(SchemaTool.java:1433)
>      [exec] 	at org.apache.openjpa.jdbc.schema.SchemaTool.run(SchemaTool.java:1403)
>      [exec] 	at org.apache.openjpa.jdbc.schema.SchemaTool$1.run(SchemaTool.java:1348)
>      [exec] 	at org.apache.openjpa.lib.conf.Configurations.launchRunnable(Configurations.java:708)
>      [exec] 	at org.apache.openjpa.lib.conf.Configurations.runAgainstAllAnchors(Configurations.java:693)
>      [exec] 	at org.apache.openjpa.jdbc.schema.SchemaTool.main(SchemaTool.java:1343)
> Albert Lee

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message