title: Hibernate annotations @ManyToMany
body: <p>I created tables in MySQL:
  role tabel , object_label and role_object_label (links table)</p>
  
  <p>I defined @ManyToMany and I gets exception.
  what the problem in my code?</p>
  
  <pre><code>@Entity
  @Table(name = "object_label")
  public class ObjectLabel  implements Serializable {
  
      private static final long serialVersionUID = 3475812350796110403L;
      private String name;
  
      public Long getId() { return id; }
  
      @Id 
      @GeneratedValue(strategy = GenerationType.AUTO)
  @Column(precision = 10, unique = true, nullable = false, updatable = false)
  public Long getId() {
      return id;
  }
  
  @Override
  public void setId( Long id ) {
      this.id = id;
  }
  
      /**
       * @return the name
       */
      public String getName() {
          return name;
      }
      /**
       * @param name the name to set
       */
      public void setName(String name) {
          this.name = name;
      }
  
  
  }
  
  
  @Entity
  @Table(name = "role")
  public class Role  implements Serializable {
  </code></pre>
  
  <p>public Long getId() { return id; }</p>
  
  <pre><code>    @Id 
      @GeneratedValue(strategy = GenerationType.AUTO)
  @Column(precision = 10, unique = true, nullable = false, updatable = false)
  public Long getId() {
      return id;
  }
  
  @Override
  public void setId( Long id ) {
      this.id = id;
  }
  
     @ManyToMany( fetch = FetchType.EAGER )
      @JoinTable(
          name = "role_object_label", joinColumns = @JoinColumn(name = "role_id"), 
          inverseJoinColumns = @JoinColumn(name = "object_label_id"))
      public Set&lt;ObjectLabel&gt; getObjectLabels(){
          return this.objectLabels;
      }
  
      /**
       * @param objectLabels the objectLabels to set
       */
      public void setObjectLabels(Set&lt;ObjectLabel&gt; objectLabels) {
          this.objectLabels = objectLabels;
      }
  
      private Set&lt;ObjectLabel&gt; objectLabels = new HashSet&lt;ObjectLabel&gt;();
  }
  </code></pre>
  
  <p>in hibernate.cfg.xml defined:</p>
  
  <pre><code>&lt;mapping class="com.myCompany.model.RoleObjectLabel" /&gt;
  &lt;mapping class="com.myCompany.model.ObjectLabel" /&gt;
  </code></pre>
  
  <p>I gets exception:</p>
  
  <pre><code>Caused by: org.hibernate.AnnotationException: Use of @OneToMany or @ManyToMany targeting an unmapped class: com.sintecmedia.model.Role.objectLabels[com.myCompany.model.ObjectLabel]
  </code></pre>
  
  <p>Thanks!
  Rivki</p>