openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Catalina Wei (JIRA)" <>
Subject [jira] Updated: (OPENJPA-679) java.lang.ArrayIndexOutOfBoundsException may occur when a relation field is annotated as a primary key and a foreign key
Date Mon, 11 Aug 2008 18:46:46 GMT


Catalina Wei updated OPENJPA-679:


Hi All,
Attaching a test scenario provided by Gopalakrishnan U that  reproduced the ArrayIndexOutOfBoundsException
in OpenJPA .

The problem is in resolving foreignkey for the following annotation in CM class of the testcase:

public class CM {

    private E e;

Notice that the ManyToOne relation is annotated as @ForeignKey and @Id,  
OpenJpa failed in resolving the  foreignKey mapping for CM entity.

Gopal worked around this problem by 
rename class C to class WC
rename class CM to WCM

OpenJPA revolves class mapping in the alphabetic order of entity names.
As you see that by renaming C to WC and CM to WCM, the entity class E gets resolved first,
hence, the forigenKey field e in CM gets resolved correctly.

Fay's patch is to making sure that foreignKey mapping is resolved no matter to in what  the
order we resolve the entities.

> java.lang.ArrayIndexOutOfBoundsException may occur when a relation field is annotated
as a primary key and a foreign key
> ------------------------------------------------------------------------------------------------------------------------
>                 Key: OPENJPA-679
>                 URL:
>             Project: OpenJPA
>          Issue Type: Bug
>            Reporter: Fay Wang
>         Attachments:, openjpa_679.patch, openjpa_679_1.patch
> <openjpa-1.2.0-SNAPSHOT-rexported nonfatal general error>
> org.apache.openjpa.persistence.PersistenceException: 0
>     at
> org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(
>     at
> org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(
>     at
> org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(
>     at
> org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(
> ....
> Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
>     at
> org.apache.openjpa.jdbc.sql.DBDictionary.getForeignKeyConstraintSQL(
>     at
> org.apache.openjpa.jdbc.sql.DBDictionary.getAddForeignKeySQL(
>     at
> org.apache.openjpa.jdbc.schema.SchemaTool.addForeignKey(
>     at org.apache.openjpa.jdbc.schema.SchemaTool.add(
>     at org.apache.openjpa.jdbc.schema.SchemaTool.add(
>     at
>     at org.apache.openjpa.jdbc.meta.MappingTool.record(
>     at org.apache.openjpa.jdbc.meta.MappingTool.record(
>     at
> org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.synchronizeMappings(
>     at
> org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.newBrokerImpl(
>     at
> org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(

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

View raw message