I'm trying to use the 2nd level cache to access a collection from a
parent entity, but don't seem to be able to work out how to get the
collection itself cached. The NH configuration enables both 2nd level
cache and query cache (using SysCache2 for the test), and setting
logging to debug shows the entities themselves being handled exactly as
I'd expect. Can anyone shed some light on what I've missed please?
Stripped-down code to demonstrate the issue (mappings done using HBM
files, each entity having <cache region="default"
usage="nonstrict-read-write" include="all" />)
public class User
{
public virtual int UserID { get; protected set; }
public virtual ISet<Assignment> Assignments { get; protected
set; }
public User()
{
this.Assignments = new HashedSet<Assignment>();
}
}
private void Test()
{
using (var session = s_sessFact.OpenSession())
{
var user = session.Get<User>(1);
// Issues a simple SQL select as expected - entity is put into cache
var assigs = user.Assignments.ToArray();
// Also issues a SQL select, as expected - each returned entity is then
cached
}
using (var session = s_sessFact.OpenSession())
{
var user = session.Get<User>(1);
// Returned from cache as expected
var assigs = user.Assignments.ToArray();
// Issues a SQL select statement - why?
}
}
Thanks,
Pete
--
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.