persistence@glassfish.java.net

Re: question about object relationships

From: Marina Vatkina <Marina.Vatkina_at_Sun.COM>
Date: Wed, 14 Mar 2007 13:58:47 -0800

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
> <http://travel.yahoo.com/hotelsearchpage;_ylc=X3oDMTFtaTIzNXVjBF9TAzk3NDA3NTg5BF9zAzI3MTk0ODEEcG9zAzIEc2VjA21haWx0YWdsaW5lBHNsawNxMS0wNw--
>> to find your fit.