Thanks for your reply Srinivas. I'm loading the user object via Session.Get, passing the ID (primary key).
Both the User and UserContactInfo object mappings do specify the <cache> node, and caching of those individual objects appears to be working fine. Problem appears only when accessing/updating the UserContactInfo object via the bag collection. Thanks again, -Daire On Mar 3, 10:51 pm, srinivas rao <[email protected]> wrote: > how are you fetching User object? is it via Session.Get() or Using criteria? > > have you added <cache> to the User class mapping? > > I think if you use Criteria you may need to enable QueryCache as well... > > > > > > > > On Fri, Mar 4, 2011 at 1:21 AM, Daire Lynch <[email protected]> wrote: > > Hi All, > > > I'm seeing odd behavior with NHibernate 3.0 (and 2.0) when I try to > > specify caching within a bag collection. Here's my mapping: > > > <bag name="UserContactInfo" inverse="true" lazy="true" > > cascade="all- > > delete-orphan"> > > <cache usage="read-write"/> > > <key column="UserNID"/> > > <one-to-many class="Domain.UserContactInfo, ... "/> > > </bag> > > > The oddness is as follows: > > 1. Start of test, clear OrgEntities cache, and load user.ContactInfo > > (a bag of objects associated with a user object). > > 2. DB has 2 records - they are read and added to the L2 cache (using > > NCache cache-provider, but I don't think that's significant). > > 3. Use NHibernate to create a new ContactInfo node and add it to the > > user. Commit. > > 4. DB is updated, now contains 3 records, but L2/NCache cache is not > > updated. HHibernate is not triggering any call to the NCache cache- > > provider's Put method for this object (which is why I don't think the > > problem is related to the cache-provider). > > 5. Second NHibernate session reads user.ContactInfo. Only 2 records > > are returned. No DB read is performed because the item is in cache – > > it’s just stale. > > > Removing the <cache> node from the bag collection fixes the issue. > > But, now my collection is not cached. Wondering if anyone has seen > > this before, if it's a known issue with NHibernate? Thanks, > > > -Daire > > > -- > > You received this message because you are subscribed to the Google Groups > > "nhusers" group. > > To post to this group, send email to [email protected]. > > To unsubscribe from this group, send email to > > [email protected]. > > For more options, visit this group at > >http://groups.google.com/group/nhusers?hl=en. -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
