If you start with Java classes, and would like for the provider to generate the
tables for you, you'll need to specify the desired mapping, but if you map to an
existing schema, part of the PK in the Port (e.g. computerId) will be a FK to
the PK in the Computer, and another field (e.g. type) will be just a PK field.
In this case a combination of 2 fields in the Post will guarantee that ComputerA
and ComputerB can have ports of the same type.
HTH,
-marina
jeff wrote On 03/14/07 14:38,:
> i still don't understand then. if there's a unidirectional relationship
> from one Computer to many Ports, then Port is only identified by it's
> type. If that's the case, then it's impossible for ComputerA and
> ComputerB to have ports of the same type.
>
> a Port's ID must somehow incorporate the Computer that it belongs to,
> and the only way i can see to do that is to have a bi-directional
> relationship. or, to manually (or automatically) assign each port a
> unique ID.
>
> is that correct?
>
> thanks.
>
> */Marina Vatkina <Marina.Vatkina_at_Sun.COM>/* wrote:
>
> It should work either way.
>
> -marina
>
> jeff wrote On 03/14/07 14:14,:
> > thanks marina, i did see that.
> >
> > then i think my question becomes: is it necessary to have a
> > bidirectional relationship to affect this behavior?
> >
> > thanks.
> >
> > */Marina Vatkina /* wrote:
> >
> > Look at the orderapp in the JavaEE tutorial - it has orders and
> > lineitems with
> > overlapping PK/FK mapping. This is most probably what you need.
> >
> > regards,
> > -marina
> >
> > jeff wrote On 03/14/07 11:25,:
> > > in a one to many (or 1-1) relationship, i want the many's ID to
> > > incorporate it's one's ID.
> > >
> > > for example, if a have a Computer that has Ports. each port has a
> > type,
> > > say "USB", "serial", etc. furthermore, say i can only have one
> of each
> > > type of port in a particular Computer.
> > >
> > > many Computers can have a Ports of the same type. how do i represent
> > > this? what is the ID for Port? the type is enough to ID it
> within the
> > > Computer, but i don't know how to represent this in JP. i think
> i want
> > > the Port's ID to incorporate the Computer's ID.
> > >
> > > in the database, i think this would mean that the table for Port
> has a
> > > foreign key pointing back to the the ID column of the table for
> > Computer.
> > >
> > > i hope this makes sense.
> > > thanks!
> > >
> > >
> > >
> >
> ------------------------------------------------------------------------
> > > Now that's room service! Choose from over 150,000 hotels
> > > in 45,000 destinations on Yahoo! Travel
> > > >> to find your fit.
> >
> >
> >
> ------------------------------------------------------------------------
> > Need Mail bonding?
> > Go to the Yahoo! Mail Q&A
> >
> > for great tips from Yahoo! Answers
> >
> > users.
>
>
> ------------------------------------------------------------------------
> Don't be flakey. Get Yahoo! Mail for Mobile
> <http://us.rd.yahoo.com/evt=43909/*http://mobile.yahoo.com/mail> and
> always stay connected
> <http://us.rd.yahoo.com/evt=43909/*http://mobile.yahoo.com/mail> to
> friends.