Have a little more information, by changing the hbm file for my
Permission entity slightly, the error I get now is :

OzoneHR.Domain.Core.Authorisation.Permission' is not a field on the
target object which is of type 'System.Collections.Generic.List`1
[OzoneHR.Domain.Core.Authorisation.Permission]

I changed the type from HashSet to List to see if that would make any
difference too.

The "test" I'm running to produce it is :

public void CanSaveProcessSetWithRoleAndPermission()
 {
            Role role = new Role("manager");
            Permission permission = new Permission
("candosomethingmeaningful", null);
            ProcessSet processSet = new ProcessSet("test process
set");

            processSet.SetPermissionOnRole(role, permission);

            _sessionManager.OpenSession().Save(permission);
            _sessionManager.OpenSession().Save(role);
            _sessionManager.OpenSession().Save
(processSet);
  }

The SetPermissionOnRole method looks like:

public virtual void SetPermissionOnRole(Role role, Permission
permission)
 {
            if (!_rolePermissions.ContainsKey(role)) _rolePermissions
[role] = new List<Permission>();
            _rolePermissions[role].Add(permission);
            //_processSetRolePermissions.AddPermissionToRole(role,
permission);
 }

Thanks,
Matt

On Nov 11, 6:06 pm, mattcole <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I have a class (RolePermissionSet) with a member like:
>
> private IDictionary<Role, HashSet<Permission>> _rolePermissions = new
> Dictionary<Role, HashSet<Permission>>();
>
> that I'm not too sure how to map.  To make things even more
> complicated, the class that it belongs to is a component of another
> mapped class.
>
> What I have is:
>
> <component name="ProcessSetRolePermissions" access="field.camelcase-
> underscore"
> class="OzoneHR.Domain.Core.Authorisation.RolePermissionSet">
>       <map name="RolePermissions"
>          access="field.camelcase-underscore"
>          table="PermissionInRoleInProcessSet"
>          cascade="all-delete-orphan"
>          lazy="false">
>         <key column="ProcessSetId" />
>         <index-many-to-many
> class="OzoneHR.Domain.Core.Authorisation.Role" column="RoleId" />
>         <many-to-many
> class="OzoneHR.Domain.Core.Authorisation.Permission"
> column="PermissionId"/>
>       </map>
>     </component>
>
> My table structure in the db is along the lines of:
>
> PermissionInRoleInProcessSet
> - ProcessSetId   int
> - RoleId int
> - PermissionId int
>
> all of which are foreign keys into other tables which map to the
> entities concerned.
>
> Is this something nHibernate can deal with or do I need to structure
> my classes differently somehow?
>
> The error I'm currently getting when trying to persist the root entity
> is:
>
> NHibernate.PropertyAccessException : Exception occurred getter of
> OzoneHR.Domain.Core.Authorisation.Permission.Id
>   ----> System.Reflection.TargetException : Object does not match
> target type.
>
> Thanks very much,
> Matt
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to