简体   繁体   English

"“多对一”属性类型不应为“持久性实体”"

[英]'Many To One' attribute type should not be 'Persistence Entity'

I'm trying out IntelliJ IDEA and it's warning me of a Hibernate association that I don't quite understand.我正在尝试 IntelliJ IDEA,它警告我有一个我不太了解的 Hibernate 关联。

One Side:一边:

@Entity
@Table(name = "MY_REQ_ASSIGNEE")
public class MyRequestAssignee extends BaseUser {
    //...
    @OneToMany(fetch = FetchType.EAGER, cascade = {CascadeType.ALL}, mappedBy = "myRequestAssignee")
    private Collection<MyRequest> myRequests = new ArrayList<>();
    //...
}

I found this to be caused by the child entity not being defined in hibernate.cfg.xml. 我发现这是由于未在hibernate.cfg.xml中定义子实体引起的。 The error message could be improved. 可以改进错误消息。

This question is a bit old, but I just wanted to add that this can also be caused by a conflicting hibernate .hbm mapping file and JPA annotations. 这个问题有点旧,但我只想补充一点,这也可能是由于冲突的hibernate .hbm映射文件和JPA注释造成的。 I ran into this error message when converting old mapping files to annotations and forgot to comment out one of the old mapping files. 我在将旧映射文件转换为注释时遇到此错误消息,并忘记注释掉其中一个旧映射文件。

I'm getting this issue in my multi-module Gradle<\/strong> project with Quarkus<\/strong> in IntelliJ<\/strong> , where I have a OneToOne reference from an entity of module A to an entity of module B.我在IntelliJ<\/strong>中使用Quarkus<\/strong>的多模块 Gradle<\/strong>项目中遇到了这个问题,其中我有一个从模块 A 的实体到模块 B 的实体的 OneToOne 引用。

在此处输入图像描述<\/a>

The code works, so I guess it could be a false flag of IntelliJ<\/strong>该代码有效,所以我猜它可能是 IntelliJ 的错误标志<\/strong>

"

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

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