Fabio, if I could not reproduce this, I'd be a much happier man then I am in fact is. Every time I run this, I get the exact same result. Did you look at the log? It clearly shows two database hits (I also see those hits in SQLProfiler). There is no doubt that the database is being queried twice. What I don't understand is why? Is there any way to get more diagnostic information?
On Jun 2, 6:16 pm, Fabio Maulo <[email protected]> wrote: > Session.CreateQuery("from Group g where groupnID > <= 5").SetCacheable(true).List<Group>(); > Session.CreateQuery("from Group g where groupnID > <= 5").SetCacheable(true).List<Group>(); > I'm pretty sure that you can't reproduce what you are saying here. > If you run the two queries above with the cache active you sure will have > only one hit to DB. > > Not only we have a lot of test about it but even I personally using query > cache in a lot of projects. > > Are you changing something in one of the spaces (Tables) involved in that > query ? > Perhaps this post may help you to understand what happening > behind:http://fabiomaulo.blogspot.com/2009/04/tuning-nhibernate-tolerant-que... > > 2009/6/2 Max Badrak <[email protected]> > > > > > Sorry, but I am not quite sure what you mean by "NHibernate.Caches" -- > > right now my lg4net configuration is just set to DEBUG at the root > > level. I tried various things during the day today, and among them I > > tried to switch from using Criteria to creating queries explicitly. So > > here is a piece of code I am actually executing (this is the only code > > that runs, there's nothing else): > > > Session.CreateQuery("from Group g where groupnID <= > > 5").SetCacheable(true).List<Group>(); > > > Session.CreateQuery("from Group g where groupnID <= > > 5").SetCacheable(true).List<Group>(); > > > This produces the log below. It seems like switching to explicit > > queries does, at least, make NH look in the cache. However, it still > > runs two DB queries (I can see the queries in the SQL Profiler), and > > neither the query itself, nor the query's results (entity IDs) are > > cached in the second level cache -- only the actual entities are > > (which I verified by dumping the entire cache). If the query cache is > > tied to the NH session, it's kind of useless for us -- our app needs > > the query results cached across multiple HTTP requests... > > > opened session > > unable to locate HQL query plan in cache; generating (from Group g > > where groupnID <= 5) > > compiling query > > HQL param location recognition took 0 mills (from Group g where > > groupnID <= 5) > > located HQL query plan in cache (from Group g where groupnID <= 5) > > find: from Group g where groupnID <= 5 > > named parameters: {} > > HQL: from Domain.Group g where groupnID <= 5 > > SQL: select group0_.GroupNID as GroupNID2_, group0_.GroupStatusID as > > GroupSta2_2_, group0_.Name as Name2_, group0_.Address1 as Address4_2_, > > group0_.Address2 as Address5_2_, group0_.City as City2_, group0_.Zip > > as Zip2_, group0_.Phone as Phone2_, group0_.Fax as Fax2_, > > group0_.ContactPerson as Contact10_2_, group0_.Comments as Comments2_, > > group0_.LastModifiedDTM as LastMod12_2_, group0_.GoLiveDate as > > GoLiveDate2_, group0_.be_OID as be14_2_, group0_.StateID as StateID2_ > > from tblGroup group0_ where (groupnID<=5 ) > > Opened new IDbCommand, open IDbCommands: 1 > > Building an IDbCommand object for the SqlString: select > > group0_.GroupNID as GroupNID2_, group0_.GroupStatusID as GroupSta2_2_, > > group0_.Name as Name2_, group0_.Address1 as Address4_2_, > > group0_.Address2 as Address5_2_, group0_.City as City2_, group0_.Zip > > as Zip2_, group0_.Phone as Phone2_, group0_.Fax as Fax2_, > > group0_.ContactPerson as Contact10_2_, group0_.Comments as Comments2_, > > group0_.LastModifiedDTM as LastMod12_2_, group0_.GoLiveDate as > > GoLiveDate2_, group0_.be_OID as be14_2_, group0_.StateID as StateID2_ > > from tblGroup group0_ where (groupnID<=5 ) > > select group0_.GroupNID as GroupNID2_, group0_.GroupStatusID as > > GroupSta2_2_, group0_.Name as Name2_, group0_.Address1 as Address4_2_, > > group0_.Address2 as Address5_2_, group0_.City as City2_, group0_.Zip > > as Zip2_, group0_.Phone as Phone2_, group0_.Fax as Fax2_, > > group0_.ContactPerson as Contact10_2_, group0_.Comments as Comments2_, > > group0_.LastModifiedDTM as LastMod12_2_, group0_.GoLiveDate as > > GoLiveDate2_, group0_.be_OID as be14_2_, group0_.StateID as StateID2_ > > from tblGroup group0_ where (groupnID<=5 ) > > select group0_.GroupNID as GroupNID2_, group0_.GroupStatusID as > > GroupSta2_2_, group0_.Name as Name2_, group0_.Address1 as Address4_2_, > > group0_.Address2 as Address5_2_, group0_.City as City2_, group0_.Zip > > as Zip2_, group0_.Phone as Phone2_, group0_.Fax as Fax2_, > > group0_.ContactPerson as Contact10_2_, group0_.Comments as Comments2_, > > group0_.LastModifiedDTM as LastMod12_2_, group0_.GoLiveDate as > > GoLiveDate2_, group0_.be_OID as be14_2_, group0_.StateID as StateID2_ > > from tblGroup group0_ where (groupnID<=5 ) > > Obtaining IDbConnection from Driver > > Opened IDataReader, open IDataReaders: 1 > > processing result set > > result set row: 0 > > returning '1' as column: GroupNID2_ > > result row: EntityKey[Domain.Group#1] > > Initializing object from DataReader: [Domain.Group#1] > > Hydrating entity: [Domain.Group#1] > > returning <bunch of junk removed> > > result set row: 1 > > <rows 1 through 4 removed> > > done processing result set (5 rows) > > running NHybridDataReader.Dispose() > > Closed IDataReader, open IDataReaders :0 > > Closed IDbCommand, open IDbCommands: 0 > > aggressively releasing database connection > > Closing connection > > total objects hydrated: 5 > > resolving associations for [Domain.Group#1] > > loading entity: [Domain.State#MA] > > creating new proxy for entity > > creating collection wrapper:[Domain.Group.Offices#1] > > adding entity to second-level cache: [Domain.Group#1] > > Caching: Domain.Group#1 > > Fetching object 'NHibernate-Cache:Domain.Group:Domain.Group#1' from > > the cache. > > Item was already cached: Domain.Group#1 > > done materializing entity [Domain.Group#1] > > resolving associations for [Domain.Group#2] > > loading entity: [Domain.State#MA] > > entity proxy found in session cache > > creating collection wrapper:[Domain.Group.Offices#2] > > adding entity to second-level cache: [Domain.Group#2] > > Caching: Domain.Group#2 > > Fetching object 'NHibernate-Cache:Domain.Group:Domain.Group#2' from > > the cache. > > Item was already cached: Domain.Group#2 > > done materializing entity [Domain.Group#2] > > resolving associations for [Domain.Group#3] > > loading entity: [Domain.State#MA] > > entity proxy found in session cache > > creating collection wrapper:[Domain.Group.Offices#3] > > adding entity to second-level cache: [Domain.Group#3] > > Caching: Domain.Group#3 > > Fetching object 'NHibernate-Cache:Domain.Group:Domain.Group#3' from > > the cache. > > Item was already cached: Domain.Group#3 > > done materializing entity [Domain.Group#3] > > resolving associations for [Domain.Group#4] > > loading entity: [Domain.State#MA] > > entity proxy found in session cache > > creating collection wrapper:[Domain.Group.Offices#4] > > adding entity to second-level cache: [Domain.Group#4] > > Caching: Domain.Group#4 > > Fetching object 'NHibernate-Cache:Domain.Group:Domain.Group#4' from > > the cache. > > Item was already cached: Domain.Group#4 > > done materializing entity [Domain.Group#4] > > resolving associations for [Domain.Group#5] > > loading entity: [Domain.State#MA] > > entity proxy found in session cache > > creating collection wrapper:[Domain.Group.Offices#5] > > adding entity to second-level cache: [Domain.Group#5] > > Caching: Domain.Group#5 > > Fetching object 'NHibernate-Cache:Domain.Group:Domain.Group#5' from > > the cache. > > Item was already cached: Domain.Group#5 > > done materializing entity [Domain.Group#5] > > initializing non-lazy collections > > after autocommit > > transaction completion > > aggressively releasing database connection > > located HQL query plan in cache (from Group g where groupnID <= 5) > > located HQL query plan in cache (from Group g where groupnID <= 5) > > find: from Group g where groupnID <= 5 > > named parameters: {} > > HQL: from Domain.Group g where groupnID <= 5 > > SQL: select group0_.GroupNID as GroupNID2_, group0_.GroupStatusID as > > GroupSta2_2_, group0_.Name as Name2_, group0_.Address1 as Address4_2_, > > group0_.Address2 as Address5_2_, group0_.City as City2_, group0_.Zip > > as Zip2_, group0_.Phone as Phone2_, group0_.Fax as Fax2_, > > group0_.ContactPerson as Contact10_2_, group0_.Comments as Comments2_, > > group0_.LastModifiedDTM as LastMod12_2_, group0_.GoLiveDate as > > GoLiveDate2_, group0_.be_OID as be14_2_, group0_.StateID as StateID2_ > > from tblGroup group0_ where (groupnID<=5 ) > > Opened new IDbCommand, open IDbCommands: 1 > > Building an IDbCommand object for the SqlString: select > > group0_.GroupNID as GroupNID2_, group0_.GroupStatusID as GroupSta2_2_, > > group0_.Name as Name2_, group0_.Address1 as Address4_2_, > > group0_.Address2 as Address5_2_, group0_.City as City2_, group0_.Zip > > as Zip2_, group0_.Phone as Phone2_, group0_.Fax as Fax2_, > > group0_.ContactPerson as Contact10_2_, group0_.Comments as Comments2_, > > group0_.LastModifiedDTM as LastMod12_2_, group0_.GoLiveDate as > > GoLiveDate2_, group0_.be_OID as be14_2_, group0_.StateID as StateID2_ > > from tblGroup group0_ where (groupnID<=5 ) > > select group0_.GroupNID as GroupNID2_, group0_.GroupStatusID as > > GroupSta2_2_, group0_.Name as Name2_, group0_.Address1 as Address4_2_, > > group0_.Address2 as Address5_2_, group0_.City as City2_, group0_.Zip > > as Zip2_, group0_.Phone as Phone2_, group0_.Fax as Fax2_, > > group0_.ContactPerson as Contact10_2_, group0_.Comments as Comments2_, > > group0_.LastModifiedDTM as LastMod12_2_, group0_.GoLiveDate as > > GoLiveDate2_, group0_.be_OID as be14_2_, group0_.StateID as StateID2_ > > from tblGroup group0_ where (groupnID<=5 ) > > select group0_.GroupNID as GroupNID2_, group0_.GroupStatusID as > > GroupSta2_2_, group0_.Name as Name2_, group0_.Address1 as Address4_2_, > > group0_.Address2 as Address5_2_, group0_.City as City2_, group0_.Zip > > as Zip2_, group0_.Phone as Phone2_, group0_.Fax as Fax2_, > > group0_.ContactPerson as Contact10_2_, group0_.Comments as Comments2_, > > group0_.LastModifiedDTM as LastMod12_2_, group0_.GoLiveDate as > > GoLiveDate2_, group0_.be_OID as be14_2_, group0_.StateID as StateID2_ > > from tblGroup group0_ where > > ... > > read more » --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
