Generally speaking, most things that apply to Hibernate apply to
NHibernate.  First Google result turned up:

http://forum.hibernate.org/viewtopic.php?t=990508&view=previous&sid=0a058cf26ddfa235da88610b871b3389

Give that a shot and see if it caches.


On Feb 3, 9:20 pm, Ayende Rahien <[email protected]> wrote:
> you need to enable query caching as well, and you need to mark the query as
> cachable.
> I don't think you can do it using FindAll
>
> On Wed, Feb 4, 2009 at 2:41 AM, jasonsirota <[email protected]> wrote:
>
> > For reference, here's my config:
>
> >    <activerecord isWeb="true" isDebug="false"
>
> > threadinfotype="Castle.ActiveRecord.Framework.Scopes.HybridWebThreadScopeInfo,
> > Castle.ActiveRecord">
> >        <config>
> >            <add key="connection.driver_class"
> > value="NHibernate.Driver.SqlClientDriver" />
> >            <add key="dialect"
> > value="NHibernate.Dialect.MsSql2005Dialect" />
> >            <add key="connection.provider"
> > value="NHibernate.Connection.DriverConnectionProvider" />
> >            <add key="connection.connection_string" value="XXX"/>
> >            <add key="proxyfactory.factory_class"
> > value="NHibernate.ByteCode.Castle.ProxyFactoryFactory,
> > NHibernate.ByteCode.Castle" />
> >            <add key="cache.provider_class"
> > value="NHibernate.Caches.SysCache.SysCacheProvider,NHibernate.Caches.SysCache"
> > /
>
> >            <add key="relativeExpiration" value="300" />
> >        </config>
> >    </activerecord>
>
> > On Feb 3, 4:37 pm, jasonsirota <[email protected]> wrote:
> > > I thought that you just had to wrap it in SessionScope, and
> > > SessionScope is enabled for the full httprequest using the httpmodule
>
> > > However, just to be safe, I wrapped it in a transaction:
>
> > >             Category[] defaultCategories;
> > >             using (new TransactionScope(OnDispose.Commit))
> > >             {
> > >                 defaultCategories = Category.FindAll();
> > >             }
>
> > > However, I still get the multiple db calls.
>
> > > On Feb 3, 4:23 pm, Stefan Sedich <[email protected]> wrote:
>
> > > > Do you not need to wrap your call to get all in a transaction? I
> > > > thought second level cache was only commited on commit of a
> > > > transaction?
>
> > > > Cheers
> > > > Stefan
>
> > > > On Wed, Feb 4, 2009 at 10:15 AM, jasonsirota <[email protected]>
> > wrote:
>
> > > > > After wrestling with the trunk version of ActiveRecord and NHibernate
> > > > > and NH-Contrib version numbers I finally got cache support enabled
> > for
> > > > > the AR project, however I'm having trouble getting it to work.
>
> > > > > The call is something like:
>
> > > > > Category.FindAll(new Order("SortOrder"),true)
>
> > > > > which returns a list of category sorted by the db field "SortOrder".
>
> > > > > I've enabled caching on the Category object like:
>
> > > > > [ActiveRecord("Categories", Cache=CacheEnum.ReadOnly)]
> > > > > public class Category
> > > > > ...
>
> > > > > However, each time the page loads, it requeries the database instead
> > > > > of pulling the resulting list from the cache.
>
> > > > > SELECT this_.CategoryID as CategoryID4_0_, this_.Description as
> > > > > Descript2_4_0_, this_.SortOrder as SortOrder4_0_, this_.Type as
> > > > > Type4_0_ FROM BudgeterCategories this_ ORDER BY this_.SortOrder asc
>
> > > > > Any ideas?
> > > > > Jason
>
> > > > --
> > > > Stefan Sedich
> > > > Software Developerhttp://weblogs.asp.net/stefansedich
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" 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/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to