Hi,
I'm using Hibernate 1.0.3 and this is generally working extremely well. However, I have a particular use case that I'm struggling to resolve. Part of my data model refers to tables that are maintained using ASP.NET web security libraries. When I call these libraries they may make database changes that occur outside of the scope of NHibernate therefore my second level cache is out of date.
As I understand it, in these situations I can use evict() on the on objects that I know to be out of date, however the next query that I run still returns the stale version of the data. Here is an example of my call to evict and the ASP.NET security:
Code:
List<String> removeProfiles = new List<String>();
string username = dmUser.Username;
foreach (DomainModel.AspnetUsersInRoles tmp in dmUser.AspnetUser.AspnetUsersInRoles) {
foreach (DomainModel.Profile profile in tmp.Role.Profiles) {
// store profile names to remove using ASP.Net security methods later...
removeProfiles.Add(profile.Name);
// evict this object from the cache, forcing a refresh on next query
mgr.evict(profile);
}
// evict this object from the cache, forcing a refresh on next query
mgr.evict(tmp);
}
// evict this object from the cache, forcing a refresh on next query
mgr.evict(dmUser);
foreach (String profileName in removeProfiles) {
Roles.RemoveUserFromRole(username, profileName);
}
// make sure that the updated user reflects underlying database changes.
dmUser = mgr.GetUser(user.Id);
What am I doing wrong?! Any help on this matter will be greatly appreciated.
Best Regards,
Chris.