Login

Username

Password





Register   Reset password

This is a read-only archive of the forum.

# haighis 11/21/2006 6:24 PM
Hi,

I am wondering why Users/Roles has a Many-to-Many relationship for the Hibernate Mapping in User.hbm.xml mapping file?

I have a scenario where one User has many Images (image filename, etc.) so I would think for this you would have in the User.hbm.xml a One-to-Many relationship whereby you have one User with many Images.

Thank You,

John Haigh
# mgaerber 11/22/2006 3:13 AM
Well,

One User can have many Roles and a Role can be assigned to many different Users (M:N).

Think of it in terms of where the Foreign Key is saved. You can have many Pictures for one User but one specific image will always be assigned to one user. The Foreign Key is saved in the Picture table (1:N).

If you would save the Foreign Key for a User in the Role table, you could assign a specific Role only to one User.