@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn (name = "account_id")
private Account account;
工作正常。
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn
private Account account;
结果:异常:SomeSchema.SomeOwnerTable 中缺少列帐户
JPA 规范说默认的连接列名是
property name ( 'account') + '_' + target table primary key ( 'id' )
但看起来 hibernate 只搜索名为“account”的属性而不是“account_id”。
有什么意见吗?
最佳答案
我认为您可以安全地删除 @JoinColumn
注释 - 无论如何都有一个连接列。
此外,请确保您没有配置特定的命名策略,这可能会覆盖默认行为。
关于Hibernate JoinColumn 默认名称缺失 '_id',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3818797/