Skip to content
Advertisement

Hibernate @ManyToOne references an unknown entity

I am receiving the following Hibernate Exception:

@OneToOne or @ManyToOne on Matchup.awayTeam references an unknown entity: Team

The simplified Matchup class looks like this:

JavaScript

The simplified Team class looks like this:

JavaScript

Notes:

  • Both Matchup and Team have subclasses. I’m not sure if this impacts the situation.
  • Both Matchup and Team are listed in my persistence.xml as being included.
  • If I put @Transient annotations on both getter methods, the error disappears.

Can anybody shed light on why this exception is occurring?

Advertisement

Answer

I figured out the problem: I was not adding class Team to the Hibernate AnnotationConfiguration object. Thus, Hibernate was not recognizing the class.

Advertisement