Hi Shelley,
first try to model this relationship as a bi-directional ManyToMany,
making the source (the future "One") side the owning side. When this
works, just drop the relationship on the target side. Note, that you'll
need a composite foreign key to address the target side (i.e. an
IdClass for the target). Maybe you can get rid of the composite pk for
the target completely, as the target side doesn't know about the source.
Cheers,
-- markus.
Shelley wrote:
I have a similar situation where a unidirectional OneToMany mapping is
needed, such that the target entity ('many' side) does not need to be aware
of the source ('one' side). The target entity, however, requires a
composite primary key with an overlapping foreign key.
It seems that the only way to resolve this is to use a bidirectional
relationship, and put knowledge of the source within the target (and
likewise the source requires knowledge of the target), which is not
desirable.
I'm curious as to whether you found an alternate solution, or if there are
any other recommendations for resolving this.
If the bidirectional relationship is required for JPA, I'd like to minimally
make this transparent to consumers of the class if possible (ie: minimize
the visibility of the required field).
farble1670 wrote:
just fyi, i am not using an existing schema, i am allowing toplink to
create it for me.
what i did that that seems to work so far is to set up a bidirectional
relationship. i am not really happy about this though, because really i
only want the direction to be one way: given a Computer i want to know the
Ports, but i'd never look up the Computer given a Port.
anyway, thanks!