带有JoinTable的ManyToOne的Hibernate外键名称

时间:2017-07-15 15:45:25

标签: hibernate spring-boot foreign-keys naming

我无法在@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

0 个答案:

没有答案