title: Hibernate Many-to-Many, duplicates same record
body: <p>I tried Hibernate Mapping Many-to-Many using Annotations with the example given in vaannila.</p>
  
  <p><a href="http://www.vaannila.com/hibernate/hibernate-example/hibernate-mapping-many-to-many-using-annotations-1.html" rel="nofollow">http://www.vaannila.com/hibernate/hibernate-example/hibernate-mapping-many-to-many-using-annotations-1.html</a></p>
  
  <pre><code>        Set&lt;Course&gt; courses = new HashSet&lt;Course&gt;();
          courses.add(new Course("Maths"));
          courses.add(new Course("Computer Science"));
  
          Student student1 = new Student("Eswar", courses);
          Student student2 = new Student("Joe", courses);
          session.save(student1);
          session.save(student2);
  </code></pre>
  
  <p>This thing works fine. But if I try to add another Course later, to a existing student like,</p>
  
  <pre><code>        Set&lt;Course&gt; courses = new HashSet&lt;Course&gt;();
          courses.add(new Course("Science"));
          Student student = new Student("Eswar", courses);
          session.save(student);
  </code></pre>
  
  <p>It duplicates the student Eswar again in the table.</p>
  
  <pre><code>        +------------+--------------+
          | STUDENT_ID | STUDENT_NAME |
          +------------+--------------+
          |          1 | Eswar        |
          |          2 | Joe          |
          |          3 | Eswar        |
          +------------+--------------+
  </code></pre>
  
  <p>Can't I add the courses to the existing Eswar?
  I really appreciate your help for this problem.</p>