lukaseder/jOOQ — Issue #7: PostgreSQL foreign-key namespace is unique-per-table, jOOQ forces all foreign keys from all tables into same namespace
Author: mikaelhg
Created: 2011-12-10 00:00:02+00:00
State: open

Given the following valid PostgreSQL DDL, jOOQ 2.0.0 will generate Java metamodel code that doesn't compile.

~~~
CREATE TABLE foo (
id SERIAL PRIMARY KEY,
baz_id INTEGER NOT NULL,
a INTEGER
);

CREATE TABLE bar (
id SERIAL PRIMARY KEY,
baz_id INTEGER NOT NULL,
b INTEGER
);

CREATE TABLE baz (
id SERIAL PRIMARY KEY,
c INTEGER
);

ALTER TABLE foo ADD CONSTRAINT baz_fk FOREIGN KEY ( baz_id )
REFERENCES baz ( id ) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE bar ADD CONSTRAINT baz_fk FOREIGN KEY ( baz_id )
REFERENCES baz ( id ) ON DELETE CASCADE ON UPDATE CASCADE;
~~~