Update:
I've answered my own question, which is no...
Not sure of my options yet.. The likely is to provide a mechanism for disabling the field level security implemented by the OLE DB provider, but I wanted to avoid this if possible...
Hibernate version: 1.2.1 GA
Is it possible to override the key used for caching an entity in the 2nd level cache?
We have a situation where the data returned from the database, depending on the user, will have certain fields null'd for security. This happens via a custom developed OLE DB provider, which we have had in commercial use for a number of years across 1,000's of customers.
Scenario 1, USER B cannot see data they should have access to:
USER A requests entity 1, which is retrieved from the database.
USER A does not have access to FIELD 1, so OLE DB provider nulls value
NHibernate caches this entity to the 2nd level cache.
USER B requests entity 1, which is retrieved from the 2nd level cache.
USER B does have access to FIELD 1, but the data is not available.
Cheers,
Stuart