title: Hibernate "ManyToOne ... references an unknown entity" exception
body: <p>I just cannot get the relationship working between my two classes mapped to SQL tables with Hibernate.</p>
  
  <p>The Role class:</p>
  
  <pre><code>@Entity
  @Table(name = "role")
  public class Role {
      @Id 
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      @Column(name="id")
      private int id;
  
      @Column(name="name")
      private String name;
  
      @OneToMany(mappedBy="memberinfo")
      private Set&lt;Memberinfo&gt; members;
  
      ...
  }
  </code></pre>
  
  <p>And the Memberinfo class:</p>
  
  <pre><code>@Entity
  @Table(name = "memberinfo")
  public class Memberinfo {
  
      @Id @GeneratedValue(strategy = GenerationType.IDENTITY)
      @Column(name="id", nullable = false)
      private int id;
  
      @Column(name = "userid", nullable = false)
      private String userid;
  
      @Column(name = "email", nullable = false)
      private String email;
  
      @Column(name = "password", nullable = false)
      private String password;
  
      @Column(name = "salt", nullable = false)
      private String salt;
  
      @Column(name = "name", nullable = false)
      private String name;
  
      @Column(name = "address")
      private String address;
  
      @Column(name = "phonenum")
      private String phonenum;
  
      @ManyToOne(targetEntity=Role.class)
      @JoinColumn(name="role_id")
      private Role role;
  
      ...
  }
  </code></pre>
  
  <p>When i try to fetch data from the DB, it connects, but throws an exception:
  "HTTP Status 500 - @OneToOne or @ManyToOne on model.Memberinfo.role references an unknown entity: model.Role".</p>
  
  <p>If i delete the variable "Role", then it works, and i can fetch the membership data, but i need the connection between the two tables, but in this case, the previously mentioned exception appears every time.</p>
  
  <p>No other solutions on stackoverflow worked for me so far.</p>
  
  <p>Any idea what am i doing wrong?</p>