Second column will not be unique and the same additional data can be associated with two different Account.CREATE TABLE acct_acctdet_jointable
(
act_details_id integer,
acct_id integer NOT NULL,
CONSTRAINT acct_acctdet_jointable_pkey PRIMARY KEY (acct_id),
CONSTRAINT fk949un3kgn8s2vbqb0sff1sto8 FOREIGN KEY (acct_id)
REFERENCES account (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT fkn66tbtylqpyf93leaxe4nk2p8 FOREIGN KEY (act_details_id)
REFERENCES account_details (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
)
To make it better unique attribute has to be set to true:
After that table in db looks:@JoinTable(name = "ACCT_ACCTDET_JOINTABLE",
joinColumns = @JoinColumn(name = "ACCT_ID"),
inverseJoinColumns = @JoinColumn(name = "ACT_DETAILS_ID", unique = true))
CREATE TABLE acct_acctdet_jointable
(
act_details_id integer,
acct_id integer NOT NULL,
CONSTRAINT acct_acctdet_jointable_pkey PRIMARY KEY (acct_id),
CONSTRAINT fk949un3kgn8s2vbqb0sff1sto8 FOREIGN KEY (acct_id)
REFERENCES account (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT fkn66tbtylqpyf93leaxe4nk2p8 FOREIGN KEY (act_details_id)
REFERENCES account_details (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT uk_9h1b7pr1yblcjd8jw2tx3wieg UNIQUE (act_details_id)
)