Use another Cache system (based on entityIdentity) or implement what your Cache provider need.
2008/11/20 tyler.burd <[EMAIL PROTECTED]> > > I've been poking around the second level cache code to make sure I > fully understand it, and I think I may have identified a potential bug > in the QueryKey class: > > * QueryKey stores a list of PositionalParameters. Normally this is > fine, but when you cache a query such as this: "from User usr where > usr.Organization = ?" (where Organization is another entity), the > PositionalParameters collection contains the Organization entity > itself. > * If the second level cache you use is out-of-process (like > Memcached), the Organization entity NEEDS to be serializable AND > implement Equals and GetHashCode to make the cache work properly. > Personally, I don't like my entities to be serializable, and if you > don't implement Equals and GetHashCode the cache just grows > indefinitely for the same query without warning. > > As far as I can tell, QueryKey should just hold the id of any entity > involved in the query. I'd be more than happy to issue a patch, I > just haven't been able to figure out how to detect that an instance is > a persistent class or how to extract just it's identifier. If someone > can point me in the right direction or tell me why I am wrong, I'd > appreciate it! > > -tyler > -- Fabio Maulo
