Hibernate Many-to-Many, duplicates same record
I tried Hibernate Mapping Many-to-Many using Annotations with the example given in vaannila. http://www.vaannila.com/hibernate/hibernate-example/hibernate-mapping-many-to-many-using-annotations-1.html Set<Course> courses = new HashSet<Course>(); 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); This thing works fine. But if I try to add another Course later, to a existing student like, Set<Course> courses = new HashSet