A semi-hidden function of the @JoinColumns annotation is to specify a @ForeignKey. Unfortunately, you're required to specify an explicit list of child @JoinColumns even when all you want to do is name the foreign key.
(All this also applies to @PrimaryKeyJoinColumns.)
Possible fixes:
specify value default {}, with the interpretation that the @JoinColumns are defaulted , or
allow @ForeignKey as a top-level annotation on association mappings (and joined inheritance mappings).
Option 2 minimizes verbosity. But at the cost of being a bit inconsistent with how @UniqueKey, @CheckConstraint, and @Index work.
A semi-hidden function of the
@JoinColumns
annotation is to specify a@ForeignKey
. Unfortunately, you're required to specify an explicit list of child@JoinColumn
s even when all you want to do is name the foreign key.(All this also applies to
@PrimaryKeyJoinColumns
.)Possible fixes:
value default {}
, with the interpretation that the@JoinColumn
s are defaulted , or@ForeignKey
as a top-level annotation on association mappings (and joined inheritance mappings).Option 2 minimizes verbosity. But at the cost of being a bit inconsistent with how
@UniqueKey
,@CheckConstraint
, and@Index
work.PR https://github.com/jakartaee/persistence/pull/638 implements option 1, which has minimal impact.