I have a class with it's own unique ID that refers to 2 other classes through many-to-one mappings. Is there a way to indicate to hibernate that the values of the 2 mappings when combined should be unique?
As an example, consider the following 3 tables
create table A
(
a_key INT PRIMARY KEY
.....
);
create table B
(
B_key INT PRIMARY KEY
.....
);
create table C
(
C_key INT PRIMARY KEY,
A_key INT NOT NULL,
B_key INT NOT NULL,
CONSTRAINT fka FOREIGN KEY (A_key) REFERENCES A(A_key),
CONSTRAINT fkb FOREIGN KEY (B_key) REFERENCES B(B_key)
);
CREATE UNIQUE INDEX IX_AB ON C(A_key,B_key);
In terms of these tables my question is; In the hibernate config files what do I use to declare the unique index on the values of C(A_key, B_key)?
thanks,
Andy
|