title: “Illegal attempt to map a non collection as a @OneToMany, @ManyToMany or @CollectionOfElements”
body: <p>Good morning Stackoverflow,</p>
  
  <p>I have the problem that it gives me the error:</p>
  
  <blockquote>
    <p>Failed to create sessionFactory
    object.org.hibernate.AnnotationException: Illegal attempt to map a non
    collection as a @OneToMany, @ManyToMany or @CollectionOfElements:
    nl.scalda.pasimo.model.employeemanagement.EducationTeam.coachGroups</p>
  </blockquote>
  
  <p>Do you know why?</p>
  
  <pre><code>@OneToMany(cascade=CascadeType.ALL, targetEntity=CoachGroup.class)
  @JoinColumn(name="id")
  private TreeSet&lt;CoachGroup&gt; coachGroups = new TreeSet&lt;&gt;();
  private SessionFactory factory;
  
  private void initialiseFactory() {
      try {
          factory = new Configuration().configure().buildSessionFactory();
      } catch (Throwable ex) {
          System.err.println("Failed to create sessionFactory object." + ex);
          throw new ExceptionInInitializerError(ex);
      }
  }
  </code></pre>