In hibernate 4.3 org.hibernate.annotations.ForeignKey declared deprecated in favor of JPA 2.1 javax.persistence.ForeignKey. But JPA annotations ignored sometimes:
for annotation: @JoinTable(name = "SPL", // joinColumns = @JoinColumn(name = "SPL_POJO_ID", foreignKey = @javax.persistence.ForeignKey(name = "SPL_FK_POJO")), // inverseJoinColumns = @JoinColumn(name = "SPL_SUB_POJO_ID", foreignKey = @ForeignKey(name = "SPL_FK_SUB_POJO"))
following schema is generated: alter table SPL add constraint FK_5nufiopmkmxpku6ash397jpwe foreign key (SPL_SUB_POJO_ID) references SUB_POJO; alter table SPL add constraint FK_23dp68pb6mw3oynxgs5lfdutf foreign key (SPL_POJO_ID) references POJO;
schema generation works as expected: alter table SPL add constraint SPL_FK_SUB_POJO foreign key (SPL_SUB_POJO_ID) references SUB_POJO; alter table SPL add constraint SPL_FK_POJO foreign key (SPL_POJO_ID) references POJO;
with old annotation: @org.hibernate.annotations.ForeignKey(name = "SPL_FK_POJO", inverseName = "SPL_FK_SUB_POJO")
example project attached
|