Interestingly, it is best to deal with such a data model: 
We have 3 objects:
Please note that entities are represented as java classes and will be displayed in the database through sleep mode. In any case, I think this question can be answered without knowledge of these technologies.
There is a many-to-many relationship between Role and User , and between Role and Permission .
Is it possible to have bidirectional communication here? So, you can ask Role to give you all its members and ask User give you all its roles.
It is very convenient that you can specify both objects, however, one of the drawbacks is that whenever you delete relations, you must manage both objects.
eg. if you remove Role from User , you must also remove User from Role . This can be very unpleasant if there are many such relationships. Therefore, I would like the best practice to be.
flash source share