Affects Version/s: 9.0peur1
Fix Version/s: not determined
Operating System: All
Apparently the Java EE spec doesn't completely specify how relationships between
entities that have composite primary and foreign keys should be handled.
In Glassfish using Toplink, if there are two entities that both have composite
primary keys and they do not match perfectly, they cannot be joined together
in a @OneToMany or @ManyToOne relationship without throwing an exception.
For example, if entityA has a composite key made up of three fields, e.g. key1,
key2, key3....and entityB has as composite PK w/ two fields, key1 and key2 - a
@OneToMany with @JoinColumns(
results in a oracle.toplink.essentials.exceptions.ValidationException.
I would provide an use-case but apparently this issue is already well
known...and code snippets & examples, plus detailed explanations can all be
found on this post in the GF forums:
This issue of legacy data that has tables w/ multiple (sometimes unmatched)
primary and foreign keys is quite common. Hibernate handles this scenario
without a problem...so it only stands to reason that Toplink should also be able
to handle it.