gpt4 book ai didi

java - 具有多个 targetEntity 的 Hibernate 映射接口(interface)

转载 作者:行者123 更新时间:2023-11-29 09:10:48 25 4
gpt4 key购买 nike

我正在尝试使用 Hibernate 和 javax.persistence 注释开发一个应用程序。我在映射接口(interface)时遇到了一些麻烦。

我已经将我的接口(interface)映射为@MappedSuperclass,并且我已经尝试在我的 ManyToOne 注释中使用属性 targetEntity 来引用该接口(interface)并且它有效。问题是我将不止一个类充当targetEntity。特别是我希望每个实现我的接口(interface)的类都可以被识别为目标实体。

有人知道这是否可行吗?

最佳答案

我认为

In particular I'd like that every class that implements my interface,could be recognized as a target entity.

不可能。只有使用 @Entity 注释或以其他方式(例如使用映射文件)映射的类才能持久化。

另外,Hibernate documentation says :

Note

Annotating interfaces is currently not supported.

参见相当古老的问题 Interfaces with hibernate annotations了解更多信息。

关于java - 具有多个 targetEntity 的 Hibernate 映射接口(interface),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12584402/

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