title: WrongClassException when assigning entries on one side of many to many relationship
body: <p>I'm using Spring Roo (and Hibernate) for a web application.</p>
  
  <p>I've got two entities  which have a MANY-TO-MANY relationship:</p>
  
  <pre><code>public class Student{
     @ManyToMany(cascade = CascadeType.ALL,mappedBy="students")
     private Set&lt;Course&gt; courses = new HashSet&lt;Course&gt;();
  }
  
  public class Course{
     @ManyToMany(cascade = CascadeType.ALL)
     private Set&lt;Student&gt; students = new HashSet&lt;Student&gt;();
  }
  </code></pre>
  
  <p>In the scaffolded GUI I can assign multiple courses to students, but when I try to assign students to courses I get this error:</p>
  
  <blockquote>
    <p>org.hibernate.WrongClassException: Object with id: null was not of the specified subclass: com.company.Student(class of the given object did not match class of persistent copy); nested exception is javax.persistence.PersistenceException: org.hibernate.WrongClassException: Object with id: null was not of the specified subclass: com.company.Student(class of the given object did not match class of persistent copy)</p>
  </blockquote>
  
  <p>What may be the cause of the problem?</p>