We're updating the issue view to help you get more done. 

Foreign key reference generated before unique constraint exists

Description

The mapping is the same as in HHH-7668.

In H2 the generated schema works:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 [main ] DEBUG - 18:27:01,763 - org.hibernate.SQL: create table Item ( id bigint not null, name varchar(255), SELLER_CUSTOMERNR varchar(255), primary key (id) ) [main ] DEBUG - 18:27:01,769 - org.hibernate.SQL: create table USERS ( id bigint not null, customerNr varchar(255), primary key (id) ) [main ] DEBUG - 18:27:01,769 - org.hibernate.SQL: alter table Item add constraint FK_76d41162ea614944b8333c7c440 foreign key (SELLER_CUSTOMERNR) references USERS (customerNr) [main ] DEBUG - 18:27:01,775 - org.hibernate.SQL: alter table USERS add constraint UK_8a5ec890d05a4545a1e9660dea0 unique (customerNr)

On Oracle this fails, as the foreign key reference is actually checked before the UNIQUE constraint is generated.

http://www.techonthenet.com/oracle/errors/ora02270.php

Environment

None

Status

Assignee

Brett Meyer

Reporter

Christian Bauer

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Affects versions

4.3.0.Beta3

Priority

Minor