Hi,

Yes, the problem is that a relation field is annotated as both a primary key 
and a foreign key. When Openjpa resolves the class matedata, it first resolves 
the primary keys of all the entities in the persistent unit. After the primary 
keys of all the entities are resolved, it then go ahead to resolve the 
non-relation field. It is normally in the stage of resolving non-relation 
fields that the foreign key is constructed.

Since  a relation field is a primary key, it gets resolved in the first stage. 
However, it is also a relation field, the foreign key is constructed in this 
stage. If the primary key information of the parent entity is not yet 
available, some of the foreign key fields will be missing. If it happens that 
the primary key information of the parent entity is already resolved (just as 
your experiment shows by manipulating the name so that the primary key of the 
parent entity gets resolved first before the child entity), then the foreign 
key constructed in this stage will be good and complete. 

The possible fix is to delay the construction of the foreign key after the 
primary keys of all the entities get resolved. I think this is an openjpa bug. 
You can file a JIRA for it.      

-fay

--- On Thu, 8/7/08, Gopalakrishnan U <[EMAIL PROTECTED]> wrote:

> From: Gopalakrishnan U <[EMAIL PROTECTED]>
> Subject: Re: ArrayIndexOutOfBoundsException:0 at 
> org.apache.openjpa.jdbc.sql.DBDictionary.getForeignKeyConstraintSQL(DBDictionary.java:3373)
> To: [email protected]
> Date: Thursday, August 7, 2008, 4:24 AM
> Found some thing interesting (or weired?) today.
> 
> When I do the following renaming the problem is gone!
> 
> rename class C to class WC
> rename class CM to WCM
> 
> i.e make those class names alphabetically higher than the
> classnames VC and
> VCS and update the persistance.xml with the new class
> names. (Changing the
> order of classes in the persistance.xml or changing the
> order of the fields
> in E etc didn't help). Any clues?
> 
> 
> 
> -- 
> View this message in context:
> http://n2.nabble.com/ArrayIndexOutOfBoundsException%3A0-at-org.apache.openjpa.jdbc.sql.DBDictionary.getForeignKeyConstraintSQL%28DBDictionary.java%3A3373%29-tp668199p678410.html
> Sent from the OpenJPA Users mailing list archive at
> Nabble.com.


      

Reply via email to