Inverse just decides which entity in a relationship is responsible for updating the database for reflecting the association.
Assume a one to many bidirectional association. There are two classes in the code A and B, A contains a set of B, B maintains a reference to A. At the database level, there is only one foreign key to be updated, the table for B contains a column to primary key of A.
In this case, assume we put the inverse = true on the set side. This implies that just adding an entity to the set will not fire the foreign key update. Because the respnsibility to update the foreign key rests with B. So, adding a B object to the set that A maintains is not enough to update the foreign key column. objectA.addToSetOfB(objectB) will not affect the foreign key.
Only when B is given a reference to A, will the foreign key in the table for B be updated. So, objectB.setA(objectA) will surely update the foreign key and actually setup the relationship.
I think the same concept will carry to the many to many relationships as well.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…