You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Gopalakrishnan (JIRA)" <ji...@apache.org> on 2008/08/08 09:42:44 UTC

[jira] Updated: (OPENJPA-682) java.lang.ArrayIndexOutOfBoundsException: 0 at at org.apache.openjpa.jdbc.sql.DBDictionary.getForeignKeyConstraintSQL() when creatingEntitymanager

     [ https://issues.apache.org/jira/browse/OPENJPA-682?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gopalakrishnan updated OPENJPA-682:
-----------------------------------

    Attachment: JIRA_682_Test.zip

Sample eclipse project that recreates the problem

> java.lang.ArrayIndexOutOfBoundsException: 0 at at org.apache.openjpa.jdbc.sql.DBDictionary.getForeignKeyConstraintSQL() when creatingEntitymanager
> --------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: OPENJPA-682
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-682
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 1.2.0
>         Environment: OpenJPA 1.2.0 SNAPSHOT (July 25th build), Derby 10.4.1.13,
>            Reporter: Gopalakrishnan
>         Attachments: JIRA_682_Test.zip
>
>
> EntityManagerFactory.createEntityManager() throws java.lang.ArrayIndexOutOfBoundsException: 0 for the sample application attached. Here is the complete trace.
> <openjpa-1.2.0-SNAPSHOT-rexported nonfatal general error> org.apache.openjpa.persistence.PersistenceException: 0
> 	at org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:196)
> 	at org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:142)
> 	at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:192)
> 	at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:145)
> 	at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:56)
> 	at jpatest.test.JPATest.setUp(JPATest.java:41)
> ...
> Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
> 	at org.apache.openjpa.jdbc.sql.DBDictionary.getForeignKeyConstraintSQL(DBDictionary.java:3373)
> 	at org.apache.openjpa.jdbc.sql.DBDictionary.getAddForeignKeySQL(DBDictionary.java:3252)
> 	at org.apache.openjpa.jdbc.schema.SchemaTool.addForeignKey(SchemaTool.java:1066)
> 	at org.apache.openjpa.jdbc.schema.SchemaTool.add(SchemaTool.java:604)
> 	at org.apache.openjpa.jdbc.schema.SchemaTool.add(SchemaTool.java:344)
> 	at org.apache.openjpa.jdbc.schema.SchemaTool.run(SchemaTool.java:321)
> 	at org.apache.openjpa.jdbc.meta.MappingTool.record(MappingTool.java:501)
> 	at org.apache.openjpa.jdbc.meta.MappingTool.record(MappingTool.java:453)
> 	at org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.synchronizeMappings(JDBCBrokerFactory.java:159)
> 	at org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.newBrokerImpl(JDBCBrokerFactory.java:119)
> 	at org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:189)
> 	... 29 more
> I enabled SQLtrace and the SQL generated for OPENJPASAMPLE.D is missing fields from its relation to VC. I am expecting create table D command to be
> CREATE TABLE OPENJPASAMPLE.D (id INTEGER NOT NULL, VC_VCID INTEGER, VC_VCS_VCSID INTEGER, VC_VCS_E_EID INTEGER, C_CID INTEGER, C_CM_CMID INTEGER, C_CM_E_EID INTEGER, PRIMARY KEY (id,VC_VCID INTEGER, VC_VCS_VCSID INTEGER, VC_VCS_E_EID INTEGER))
> Given below is the SQLTrace:
> 8015  test  TRACE  [main] openjpa.jdbc.SQL - <t 19105669, conn 26625789> executing stmnt 31447311 CREATE TABLE OPENJPASAMPLE.C (cId INTEGER NOT NULL, CM_CMID INTEGER NOT NULL, CM_E_EID INTEGER NOT NULL, PRIMARY KEY (cId, CM_CMID, CM_E_EID))
> 8187  test  TRACE  [main] openjpa.jdbc.SQL - <t 19105669, conn 26625789> [172 ms] spent
> 8187  test  TRACE  [main] openjpa.jdbc.SQL - <t 19105669, conn 24422114> executing stmnt 29499086 CREATE TABLE OPENJPASAMPLE.CM (cmId INTEGER NOT NULL, E_EID INTEGER NOT NULL, PRIMARY KEY (cmId, E_EID))
> 8343  test  TRACE  [main] openjpa.jdbc.SQL - <t 19105669, conn 24422114> [156 ms] spent
> 8359  test  TRACE  [main] openjpa.jdbc.SQL - <t 19105669, conn 15184882> executing stmnt 2011334 CREATE TABLE OPENJPASAMPLE.D (id INTEGER NOT NULL, C_CID INTEGER, C_CM_CMID INTEGER, C_CM_E_EID INTEGER, PRIMARY KEY (id))
> 8484  test  TRACE  [main] openjpa.jdbc.SQL - <t 19105669, conn 15184882> [125 ms] spent
> 8500  test  TRACE  [main] openjpa.jdbc.SQL - <t 19105669, conn 27921979> executing stmnt 22823147 CREATE TABLE OPENJPASAMPLE.E (eId INTEGER NOT NULL, PRIMARY KEY (eId))
> 8750  test  TRACE  [main] openjpa.jdbc.SQL - <t 19105669, conn 27921979> [250 ms] spent
> 8750  test  TRACE  [main] openjpa.jdbc.SQL - <t 19105669, conn 8993129> executing stmnt 21731956 CREATE TABLE OPENJPASAMPLE.VC (vcId INTEGER NOT NULL, VCS_E_EID INTEGER NOT NULL, VCS_VCSID INTEGER NOT NULL, PRIMARY KEY (vcId, VCS_E_EID, VCS_VCSID))
> 8890  test  TRACE  [main] openjpa.jdbc.SQL - <t 19105669, conn 8993129> [140 ms] spent
> 8906  test  TRACE  [main] openjpa.jdbc.SQL - <t 19105669, conn 18439211> executing stmnt 7202313 CREATE TABLE OPENJPASAMPLE.VCS (E_EID INTEGER NOT NULL, vcsId INTEGER NOT NULL, PRIMARY KEY (E_EID, vcsId))
> 9047  test  TRACE  [main] openjpa.jdbc.SQL - <t 19105669, conn 18439211> [141 ms] spent
> 9047  test  TRACE  [main] openjpa.jdbc.SQL - <t 19105669, conn 18602441> executing stmnt 10023314 ALTER TABLE OPENJPASAMPLE.C ADD FOREIGN KEY (CM_CMID, CM_E_EID) REFERENCES OPENJPASAMPLE.CM (cmId, E_EID)
> 9156  test  TRACE  [main] openjpa.jdbc.SQL - <t 19105669, conn 18602441> [109 ms] spent
> 9156  test  TRACE  [main] openjpa.jdbc.SQL - <t 19105669, conn 18529640> executing stmnt 24685281 ALTER TABLE OPENJPASAMPLE.CM ADD FOREIGN KEY (E_EID) REFERENCES OPENJPASAMPLE.E (eId)
> 9250  test  TRACE  [main] openjpa.jdbc.SQL - <t 19105669, conn 18529640> [94 ms] spent
> <openjpa-1.2.0-SNAPSHOT-rexported nonfatal general error> org.apache.openjpa.persistence.PersistenceException: 0
> 	at org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:196)
> So I am assuming that it is failing at generation of foreign key command for OPENJPASAMPLE.D table. 
> When the classes C and CM are renamed to WC and WCM (i.e alphabetically higher than VC and VCS) the problem goes away. 
> Here is link to post regarding this problem in the OpenJPA user list : http://n2.nabble.com/ArrayIndexOutOfBoundsException%3A0-at-org.apache.openjpa.jdbc.sql.DBDictionary.getForeignKeyConstraintSQL%28DBDictionary.java%3A3373%29-td668199.html

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