The problem is the generated DDL:
CREATE TABLE public.a_b_aud (
b_id BIGINT NOT NULL,
rev INTEGER NOT NULL,
a_id BIGINT NOT NULL,
CONSTRAINT a_b_aud_pkey PRIMARY KEY(a_id, rev),
CONSTRAINT fk_5689e745b66c4ee2a8822e44079 FOREIGN KEY (b_id, rev)
REFERENCES public.b_aud(id, rev)
ON DELETE NO ACTION
ON UPDATE NO ACTION
NOT DEFERRABLE,
CONSTRAINT fk_b5c868c4f5f34d35bdb7a6c1281 FOREIGN KEY (a_id, rev)
REFERENCES public.a_aud(id, rev)
ON DELETE NO ACTION
ON UPDATE NO ACTION
NOT DEFERRABLE
) WITHOUT OIDS;
The b_id
column should be nullable as Envers expect it to be. Just like the same column in public.a_b
table. I believe the problem is limited to the DDL generator.
The A
to B
OneToOne relationship is bidirectionally optional and A
is the owner, that's why b_id
can be nullable and why primary key points to PRIMARY KEY(a_id, rev)
.