title: Hibernate: OneToMany in the same table
body: <p>I have the following ‘class’ table:</p>
  
  <pre><code>integer id
  integer class_id
  integer student_id
  </code></pre>
  
  <p>The point here is that it's possible to have multiple <code>student_ids</code> under the same <code>class_id</code>.</p>
  
  <p>Is it possible to map it to an entity that looks like this:</p>
  
  <pre><code>@Entity
  @Table(name = "class")
  class MyClass {
     @Id
     @Column(name = "class_id")
     long classId;
  
     @OneToMany(mappedBy = "student_id")
     List&lt;Long&gt; studentIds;
  }
  </code></pre>
  
  <p>How to make this work?</p>