我无法在@ManyToOne
注释属性上为@JoinTable
关系设置外键名称,它只是忽略了我的设置。我使用的是Spring-Boot 1.5.4,它使用的是Hibernate 5.0.12。
@ManyToOne
@JoinTable(
name = "PROPERTY_CREDIT_OPTIONS",
joinColumns = @JoinColumn(name = "CREDIT_ID", nullable = false, foreignKey = @ForeignKey(name = "FK_PROPERTY_CREDIT_OPTIONS_TO_CREDIT"), unique = true),
inverseJoinColumns = @JoinColumn(name="PROPERTY_ID", nullable = false, foreignKey = @ForeignKey(name = "FK_PROPERTY_CREDIT_OPTIONS_TO_PROPERTY")),
foreignKey = @ForeignKey(name="FK_PROPERTY_CREDIT_OPTIONS_TO_CREDIT"),
inverseForeignKey = @ForeignKey(name="FK_PROPERTY_CREDIT_OPTIONS_TO_PROPERTY")
)
@NotNull @NonNull
Property property;
结果:
alter table property_credit_options add constraint FKp22j0sq9hexrde9yoyjbj40w2 foreign key (property_id) references property
alter table property_credit_options add constraint FKq8tof33debkfgy0lmp7n5p3we foreign key (credit_id) references not_active_credit