I have a problem, and I can't fix it. I have two entitys connected with a join table.(many to many).
I insert a row in database. In another session, when I try do add another row it delets before it insert it. For example `example
Meeting meeting1 = new Meeting("Quaterly Sales meeting");
Meeting meeting2 = new Meeting("Weekly Status meeting");
Employee employee1 = new Employee("Sergey", "Brin");
Employee employee2 = new Employee("Larry", "Page");
employee1.getMeetings().add(meeting1);
employee1.getMeetings().add(meeting2);
employee2.getMeetings().add(meeting1);
session.save(employee1);
session.save(employee2);
now If a create another session another time,
Meeting meeting2 = new Meeting("new");
Employee employee1 = new Employee("new", "new");
employee1.getMeetings().add(meeting2);
It Deletes all the previous data in the join table(EMPLOYEE_MEETING), and in table remains only the last.
There is a thread in forum thread that says I should write equals and hashcode. I generate via eclipse the hashcode() and equals() but its still the same, Hibernate deletes before insterts. Any idea how to stop this ? thank you very much.