views:

24

answers:

0

I am having trouble working out how to correctly cache one-to-many or many-to-many relationships in NHibernate.

For example, an office class may have the following mapping:

public OfficeDbMap()
{
    ...
    HasMany(x => x.Employees)
        .Cache.NonStrictReadWrite();
}

However I find that when I delete an employee (without specifically removing its relationship to the office), that the cache of office->employees does not get invalidated and the employee continues to appear in the office's list of employees.

I suspect it may have something to do with cache regions, but I don't know whether the region should be the office's region or the employee's region (actually I have tried specifying both and neither works).