休眠@ManyToOne "Target Entity is not defined"

Hibernate @ManyToOne "Target Entity is not defined"

我有两个实体,当我使用@ManyToOne 注释时,我收到一条错误消息 "Target Entity is not defined"

我只是在学习教程,我似乎找不到我做错了什么。

        @Entity
        @Table(name="BEO_TABLE")
        public class BeoBean {

            @Id
            @GeneratedValue
            @Column(name="Beo_Id")
            private int beoId;

    //other variables


            @OneToMany(mappedBy="beo")
            private List<EventsBean> listOfEvents = new ArrayList<EventsBean>();

    //getters and setters
}

AND

@Entity
@Table(name="EVENTS_TABLE")
public class EventsBean {

    //other variables

    @ManyToOne //error here
    @JoinColumn(name="Beo_Id")
    private BeoBean beo;

//getters and setters
}

感谢您的帮助

此错误与您的应用程序无关。它工作正常,但错误在 Eclipse.

要删除此(和其他 JPA)错误消息,只需在 Window -> Preferences -> Validation 下禁用 JPA 验证并在此处删除 JPA Validator.

中的检查

通常大多数应用程序都可以在没有任何验证器的情况下开发,因为较大的项目的验证会减慢在 Eclipse 中编译的速度。在这种情况下,单击 table 验证器下方相同 window 中的 Disable all

修复您在 Eclipse 中的持久性单元。将 BeoBean 添加到 PU。你应该被排序

225/5000 我在Eclipse中经常出现这种假错误,通过清理项目解决了。

Select 项目,然后单击项目/清理 ... 菜单,然后单击清理按钮

再次为我工作。

JJMB