Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hibernate @ManyToOne "Target Entity is not defined"

I have two entities, and when i use @ManyToOne annotation, i'm getting an error saying "Target Entity is not defined".

I'm just following a tutorial and i can't seem to find what i did wrong.

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

Thanks for your help

like image 202
pat3ck029 Avatar asked Oct 23 '15 03:10

pat3ck029


2 Answers

This error has nothing to do with your application. It works fine but the error is in Eclipse.

To remove this (and other JPA) error message simply disable the JPA validation under Window -> Preferences -> Validation and here remove the checks from JPA Validator.

Generally most applications can be developed without any validators because bigger projects' validation slows down compiling in eclipse way too much. In this case click Disable all in the same window below the table of validators.

like image 115
GHajba Avatar answered Sep 26 '22 14:09

GHajba


Fix your persistence unit in eclipse. Add BeoBean to the PU. You should be sorted

like image 32
KameshG Avatar answered Sep 25 '22 14:09

KameshG