In the many-to-many relationship between the employee table and the department table, when setting up the department collection through the employee table, it was found that the intermediate table automatically deleted records, but no updated data was inserted, as follows:
refer to:
Employee table:
Department table:
Please tell me how to update the department set field of the employee table through the set method of the employee table in the following code, and at the same time automatically update the intermediate table, that is, the intermediate table should insert new records after deleting records.
When asking questions, it is best not to take screenshots of the code, but to post the source code so that others can view and simulate it
I don’t know if this is correct, I think your problem is that you should add cascade or inverse cascade in the configuration file