Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NHibernate cache/deletion problem?

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.

like image 633
Mark Embling Avatar asked Oct 15 '22 08:10

Mark Embling


1 Answers

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.

like image 186
ddango Avatar answered Nov 09 '22 23:11

ddango