gpt4 book ai didi

java - 如何对@Any 注释属性进行双向映射?

转载 作者:搜寻专家 更新时间:2023-10-31 19:50:35 24 4
gpt4 key购买 nike

在这篇文章中http://www.jroller.com/eyallupu/entry/hibernate_the_any_annotation还有这个问题 How to use Hibernate @Any-related annotations? ,解释了如何使用 @Any 注释。但是我怎样才能借到每张 DVD/VHS/BOOK? DVD/VHS/BOOK如何映射定义?

最佳答案

认为这不受支持,并且如文档中所述:

2.4.5.2. @Any

The @Any annotation defines a polymorphic association to classes from multiple tables. This type of mapping always requires more than one column. The first column holds the type of the associated entity. The remaining columns hold the identifier. It is impossible to specify a foreign key constraint for this kind of association, so this is most certainly not meant as the usual way of mapping (polymorphic) associations. You should use this only in very special cases (eg. audit logs, user session data, etc).

虽然我知道引入此注解是为了将关联属性映射到没有共同祖先实体的不同类型的实体,但我认为引入其他实体将从其继承的基类型会更好双向关系。

另见

关于java - 如何对@Any 注释属性进行双向映射?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3212317/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com