简体   繁体   English

JPA继承:不同子类中的相同属性

[英]JPA Inheritance: same property in different subclasses

so I have a single table inheritance with A being my base class and A1,A2,A3 all extend A. A2 and A3 both have a property named "name". 因此,我有一个表继承,其中A是我的基类,而A1,A2,A3都扩展了A。A2和A3都有一个名为“名称”的属性。 Will it get me in trouble if I map A2.name and A3.name to the same table column? 如果我将A2.name和A3.name映射到同一表列,会给我带来麻烦吗? I'm not getting any errors so far, but I'm worried about strange behavior in the future. 到目前为止,我还没有收到任何错误,但是我担心将来会出现奇怪的行为。

I'm using hibernate 4.3+ 我正在使用休眠4.3+

so far I haven't encountered any problems, so it's all good. 到目前为止,我还没有遇到任何问题,所以一切都很好。

But this is only the case for normal properties. 但这只是普通属性的情况。 Adding A2.address and A3.address where "address" is a ManyToOne- or OneToOne- Relation to another entity, then things will not work anymore. 将A2.address和A3.address添加到另一个实体,其中“地址”是另一个实体的ManyToOne-或OneToOne-关系。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM