可嵌入类中的 ManyToOne 列
我有两个嵌入 (@Embedded
) 可嵌入地址的实体。在 Adress 类中,有一个属性指向实体 Location。在 Adress 类中,我将 @ManyToOne
和 @JoinColumn(...)
注释放在其上方。现在我得到这个错误:
异常描述:表 [人] 不存在于此 描述符。描述: RelationalDescriptor(com.wordpress.aiids.voeder.model.Location --> [数据库表(位置)])
这是 @JoinColumn
注释导致了问题:
@ManyToOne
//@JoinColumn(name = "gemeente", referencedColumnName = "gemeente", nullable = false)
private Gemeente gemeente;
这是可嵌入类的完整代码。
http://aiids.pastebin.com/G1sijNBL
我把这些注释放在那里会做错什么吗?这个错误的原因是什么?
解决方案!
解决方案是referencedColumnName
必须指向实体Gemeente的主键,即“postcode”而不是“gemeente”。
I have two entities who embed (@Embedded
) the Adress embeddable. In the Adress class there is a property who points to an entity Location. In the Adress class I put @ManyToOne
and @JoinColumn(...)
annotations above it. Now I get this error:
Exception Description: The table
[persons] is not present in this
descriptor. Descriptor:
RelationalDescriptor(com.wordpress.aiids.voeder.model.Location
--> [DatabaseTable(locations)])
It's the @JoinColumn
annotation that causes the trouble:
@ManyToOne
//@JoinColumn(name = "gemeente", referencedColumnName = "gemeente", nullable = false)
private Gemeente gemeente;
Here's the full code of the embbedable class.
http://aiids.pastebin.com/G1sijNBL
Do I do something wrong by putting those annotations there or what's the cause of this error?
SOLUTION!
The solution is that the referencedColumnName
must point to the Primary Key of the Entity Gemeente which was "postcode" and not "gemeente".
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论