Hello,
I want to set up an user authorization system with NHibernate 1.2.0 beta1. I have two relevant classes (here in pseudo syntax):
Code:
class Permission
{
[PrimaryKey]
String InternalName{ get; set; }
String ExternalName{ get; set; }
}
class UserGroup
{
[PrimaryKey]
int Id { get; set; }
String Name { get; set; }
IList<Permission> GrantedPermissions { get; set; }
IList<Permission> RevokedPermissions { get; set; }
}
I was thinking of three tables: UserGroups, Permissions, UserGroups_Permissions.
UserGroup_Permissions should contain three columns: (PermissionInternalName, UserGroupId, PermissionType) where PermissionType = 'G' if and only if the permission was granted and PermissionType = 'R' if and only if the permission was revoked.
I tried this with:
Code:
<bag name="GrantedPermissions" table="UserGroups_Permissions" where="PermissionType = 'G'">
<key column="UserGroupId" />
<many-to-many class="Permission" column="PermissionInternalName" />
</bag>
Is this scenario possible or do I need two relation tables?
Regards and thanks in advance,
Dominik