Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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<>();
    //...
}

Many Side:

@Entity
@Table(name = "MY_REQUEST")
public class MyRequest implements Persistable {

   //...
   @ManyToOne(fetch=FetchType.EAGER)
   @JoinColumn(name="ASSIGNEE_ID")
   private MyRequestAssignee myRequestAssignee;
   //...
}

(Persistable is just an interface that has the id property to make sure Hibernate has access to it.)

I see the MyRequestAssignee type underlined in red and the message reads 'Many To One' attribute type should not be 'Persistence Entity'. Are there something wrong with my relationships?

For a sanity check, I looked at this post and this post too.

like image 649
vphilipnyc Avatar asked Aug 20 '15 16:08

vphilipnyc


1 Answers

I found this to be caused by the child entity not being defined in hibernate.cfg.xml. The error message could be improved.

like image 103
Phil Carter Avatar answered Nov 02 '22 09:11

Phil Carter