You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jdo-dev@db.apache.org by Craig Russell <Cr...@Sun.COM> on 2005/05/29 05:28:08 UTC
Issue 119: cannot add a constraint to a join table
Javadogs,
There is no way to specify a constraint except on the columns mapped to
fields in a class. So, there can be a foreign key defined for the join
columns or for the mapped columns but there is no way to define a
unique or primary key constraint on multiple columns in a join table.
I can't see how to do this easily. Is this even an issue? Anyone else?
Craig
Craig Russell
Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
408 276-5638 mailto:Craig.Russell@sun.com
P.S. A good JDO? O, Gasp!
RE: Issue 119: cannot add a constraint to a join table
Posted by er...@jpox.org.
It's supported under class elements, but IMO it's cleaner and straight
forward to set the constraints and whatever related inside the
associations <join>.
The declaration under class implies that we always have cardinality
greater than 1 for any element, like primary-key.
<class table="PERSON">
<primary-key table="PERSON">
...
</primary-key>
<primary-key table="PERSON_DEPT">
...
</primary-key>
...
It doesn't look good to me, and more, we can set primary-key or other
constraints for any table wherever we are.
<class table="APPLE">
<primary-key table="PERSON">
...
</primary-key>
<primary-key table="PERSON_DEPT">
...
</primary-key>
...
Erik Bengtson
-----Original Message-----
From: Craig Russell [mailto:Craig.Russell@Sun.COM]
Sent: Sunday, May 29, 2005 9:09 PM
To: Abe White
Cc: JDO Expert Group; jdo-dev@db.apache.org
Subject: Re: Issue 119: cannot add a constraint to a join table
Hi Abe,
Learn something every day.
So in order to define a primary key constraint on a join table, I'll
have to amend my primary-key proposal to include multiple column
elements and name= and table= attributes.
Thanks,
Craig
On May 29, 2005, at 11:56 AM, Abe White wrote:
>> Sorry, Abe, I should have reiterated the subject in the text. I'm
>> talking about the fact that you cannot define constraints for join
>> tables and tables used to contain Map and List fields. It's possible
>> to define constraints on mapped columns of classes.
>
> Sure you can. That's why the class-level constraint element have a
> "table" attribute.
>
>
Craig Russell
Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
408 276-5638 mailto:Craig.Russell@sun.com
P.S. A good JDO? O, Gasp!
Re: Issue 119: cannot add a constraint to a join table
Posted by Craig Russell <Cr...@Sun.COM>.
Hi Abe,
Learn something every day.
So in order to define a primary key constraint on a join table, I'll
have to amend my primary-key proposal to include multiple column
elements and name= and table= attributes.
Thanks,
Craig
On May 29, 2005, at 11:56 AM, Abe White wrote:
>> Sorry, Abe, I should have reiterated the subject in the text. I'm
>> talking about the fact that you cannot define constraints for join
>> tables and tables used to contain Map and List fields. It's possible
>> to define constraints on mapped columns of classes.
>
> Sure you can. That's why the class-level constraint element have a
> "table" attribute.
>
>
Craig Russell
Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
408 276-5638 mailto:Craig.Russell@sun.com
P.S. A good JDO? O, Gasp!
Re: Issue 119: cannot add a constraint to a join table
Posted by Abe White <aw...@solarmetric.com>.
> Sorry, Abe, I should have reiterated the subject in the text. I'm
> talking about the fact that you cannot define constraints for join
> tables and tables used to contain Map and List fields. It's possible
> to define constraints on mapped columns of classes.
Sure you can. That's why the class-level constraint element have a
"table" attribute.
Re: Issue 119: cannot add a constraint to a join table
Posted by Craig Russell <Cr...@Sun.COM>.
Sorry, Abe, I should have reiterated the subject in the text. I'm
talking about the fact that you cannot define constraints for join
tables and tables used to contain Map and List fields. It's possible to
define constraints on mapped columns of classes.
Craig
On May 28, 2005, at 10:23 PM, Abe White wrote:
>> There is no way to specify a constraint except on the columns mapped
>> to fields in a class.
>
> You can define constraints beneath the <class> element, and these
> constraints can contain column elements for constraints on arbitrary
> column sets. This is already described in the spec. If this doesn't
> satisfy what you're looking for, then could you clarify exactly what
> you think is lacking?
>
>
Craig Russell
Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
408 276-5638 mailto:Craig.Russell@sun.com
P.S. A good JDO? O, Gasp!
Re: Issue 119: cannot add a constraint to a join table
Posted by Abe White <aw...@solarmetric.com>.
> There is no way to specify a constraint except on the columns mapped
> to fields in a class.
You can define constraints beneath the <class> element, and these
constraints can contain column elements for constraints on arbitrary
column sets. This is already described in the spec. If this doesn't
satisfy what you're looking for, then could you clarify exactly what
you think is lacking?