views:

45

answers:

1

I am using NHibernate and have a cache region specified in my NHibernate configuration:

<cache region="HalfHour" expiration="1800" priority="3" />

I have an entity definition (UserDefinedGroup) which is set to use this cache region in read-write mode:

<class name="UserDefinedGroup" table="Message_Groups">
    <cache region="HalfHour" usage="read-write" />
    ...
</class>

I also have an HQL query that is set to use the query cache as it returns a large number of UserDefinedGroup instances:

var results = Session.CreateQuery("from UserDefinedGroup order by Name")
                .SetCacheable(true)
                .SetCacheRegion("HalfHour")
                .List<UserDefinedGroup>();

However, when I try and delete an instance of UserDefinedGroup I receive the following error even though the entity is set to use read-write cache.

ReadOnlyCache: Can't write to a readonly object Cristal.Model.UserDefinedGroups.UserDefinedGroup

Am I completely missing the point or misunderstanding NHibernate caching here? I'd expect this to perform the delete and the cache take care of itself appropriately, but clearly this is not happening.

+1  A: 

Is this cache region used by any other entities? If so, are there usages of the cache that are read-only? A specific region should only have one usage type.

ddango