简体   繁体   中英

'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.

@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. 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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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