users@jpa-spec.java.net

[jpa-spec users] [jsr338-experts] ForeignKey annotation [Re: Re: updated spec draft and xsds]

From: Linda DeMichiel <linda.demichiel_at_oracle.com>
Date: Mon, 11 Feb 2013 11:48:31 -0800

Here's my assessment of the issue.

Ideally, I think foreign-key metadata should be kept in the
JoinColumn(s) annotations. However, for compound primary keys
we have JoinColumn[] elements (or related elements) in the
JoinTable, CollectionTable, and SecondaryTable annotations, which
do not support this cleanly.

I see several options (none unfortunately ideal):

1) Move @ForeignKey to top level. I think this gets messy because
     it allows for a lot of overlap in where it might be specified.

2) Add @ForeignKey elements to JoinTable, CollectionTable, and SecondaryTable
     and clarify that they are to be used for compound FKs.

3) Clarify that for compound foreign keys, in JoinTable, CollectionTable,
     and SecondaryTable that at most one of the joinColumn elements should
     be used to hold the FK metadata for the compound FK.

Am I missing anything?

Do any of you see a better way?

So far, I am leaning toward #3 as the least objectionable.

Opinions??

thanks,

-Linda




On 2/8/2013 9:33 AM, Linda DeMichiel wrote:
> Sigh. This is a bug (and with the other @XXXTable mappings that allow joinColumns to be
> specified). I intended compound FKs to be handled in @JoinColumns, but these mapping
> types don't have a @JoinColumns subelement by rather a JoinColumn[] element.
>
> Will need to reevaluate.
>
> thanks,
>
> -Linda
>
>
> On 2/8/2013 9:07 AM, Steve Ebersole wrote:
>> There is a discrepency between orm.xsd and the spec. orm.xsd defines that join-table lists that foreign-key should be a
>> sub-element, however @JoinTable does not define a foreignKeys attribute.
>>
>>
>> On Tue 05 Feb 2013 06:48:12 PM CST, Linda DeMichiel wrote:
>>>
>>> I've posted a new spec draft with the updated schema generation metadata
>>> to the project Downloads area. This draft also contains the updated
>>> persistence and orm schemas. I have also uploaded these xsd files to
>>> the Downloads area.
>>>
>>> Notice that the namespace in the schemas has changed, as we will no
>>> longer
>>> be using java.sun.com for new work. There are no other modifications to
>>> the schema for the persistence.xml, but since we have changed the orm
>>> schema,
>>> I figured it would be less confusing if both xsd files were updated.
>>>
>>> -Linda