java - In hibernate bidirectional many-to-many relationship, how to automatically update the intermediate table when one of the parties is modified?
阿神
阿神 2017-05-17 10:03:35
0
2
617

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.

阿神
阿神

闭关修行中......

reply all(2)
伊谢尔伦

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template