两个相关 JPA 实体之间的接口
该场景如下(所示表格)
Delivery table
------
id channelId type
10 100 fax
20 200 email
Fax table
----
id number
100 1234567
101 1234598
Email table
-----
id email
200 [email protected]
201 [email protected]
基本上是交付和渠道实体之间的一对一关系,但由于每个具体渠道(传真、电子邮件)都有不同的成员,我想在两个实体之间创建一个通用接口(渠道),并且将其用于@OneToOne 关系。在我看来,这是一个简单的场景,你们中的很多人可能已经经历过,但我无法成功。我尝试放置 targetEntity 的东西但没有用。仍然说“交付引用未知实体”
有什么想法吗?提前致谢
The scenario is as below (tables shown)
Delivery table
------
id channelId type
10 100 fax
20 200 email
Fax table
----
id number
100 1234567
101 1234598
Email table
-----
id email
200 [email protected]
201 [email protected]
basically a one to one relationship between the delivery and the channel entity but since each concrete channel(fax, email) has different members I want to create a generic interface (channel) between the two entities and use it for the @OneToOne relationship. Seems to me a simple scenario where lot of you might have already gone through but I'm unable to succeed. I tried putting that targetEntity thing but no use. Still says "delivery references an unknown entity"
Any ideas? thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为
Channel
使用abstract
超类和TABLE_PER_CLASS
继承策略怎么样?像这样的事情:What about using an
abstract
super class for theChannel
and aTABLE_PER_CLASS
inheritance strategy? Something like this: