SQL queries work without required them to be named queries. You were asking
about caching, so I thought you had the query working before you tried
putting it into a cache. I suggest that you should try to approach it by
making the sql query you want work first, then try adding it to your cache
setup.

Try:
http://knol.google.com/k/fabio-maulo/nhibernate-chapter-14/1nr4enxv3dpeq/17#

John Davidson

On Mon, Apr 12, 2010 at 4:34 AM, Kent Boogaart <[email protected]>wrote:

> Thanks for the links, but neither appears to address the problem. The
> second link didn't work but I found what I think is the same article
> at
> http://davybrion.com/blog/2009/02/quickly-setting-up-and-using-nhibernates-second-level-cache/
> .
>
> My problem is that I'm using SQL queries without a named query. Doing
> so throws an exception as per my original post. Is this scenario not
> supported?
>
> Thanks,
> Kent
>
> On Apr 9, 7:17 pm, John Davidson <[email protected]> wrote:
> > The links below give hints as to the secret sauce for configuring cache
> >
> >
> http://ayende.com/Blog/archive/2006/08/21/TheSecretLifeOfNHibernatesC...http://nhforge.org/blogs/nhibernate/archive/2009/02/09/quickly-settin.
> ..
> >
> > John Davidson
> >
> > On Fri, Apr 9, 2010 at 12:26 PM, Kent Boogaart <[email protected]
> >wrote:
> >
> > > Hi,
> >
> > > I have a SQL query:
> >
> > >    var filterValues = session
> > >        .CreateSQLQuery(sql)
> > >        ////.SetCacheable(true)
> > >        .SetParameter("parent", qualifiedName)
> > >
>  .SetResultTransformer(Transformers.AliasToBean(typeof(FilterValue)))
> > >        .List<FilterValue>();
> >
> > > The actual SQL does not appear to matter. If I uncomment the
> > > SetCacheable call I get an exception:
> >
> > > System.IndexOutOfRangeException: Index was outside the bounds of the
> > > array.
> > >   at NHibernate.Type.TypeFactory.Disassemble(Object[] row,
> > > ICacheAssembler[] types, Boolean[] nonCacheable, ISessionImplementor
> > > session, Object owner)
> > >   at NHibernate.Cache.StandardQueryCache.Put(QueryKey key,
> > > ICacheAssembler[] returnTypes, IList result, Boolean
> > > isNaturalKeyLookup, ISessionImplementor session)
> > >   at
> > > NHibernate.Loader.Loader.PutResultInQueryCache(ISessionImplementor
> > > session, QueryParameters queryParameters, IType[] resultTypes,
> > > IQueryCache queryCache, QueryKey key, IList result)
> > >   at NHibernate.Loader.Loader.ListUsingQueryCache(ISessionImplementor
> > > session, QueryParameters queryParameters, ISet`1 querySpaces, IType[]
> > > resultTypes)
> > >   at NHibernate.Loader.Loader.List(ISessionImplementor session,
> > > QueryParameters queryParameters, ISet`1 querySpaces, IType[]
> > > resultTypes)
> > >   at NHibernate.Loader.Custom.CustomLoader.List(ISessionImplementor
> > > session, QueryParameters queryParameters)
> > >   at NHibernate.Impl.SessionImpl.ListCustomQuery(ICustomQuery
> > > customQuery, QueryParameters queryParameters, IList results)
> > >   at NHibernate.Impl.SessionImpl.List(NativeSQLQuerySpecification
> > > spec, QueryParameters queryParameters, IList results)
> > >   at NHibernate.Impl.SessionImpl.List[T](NativeSQLQuerySpecification
> > > spec, QueryParameters queryParameters)
> > >   at NHibernate.Impl.SqlQueryImpl.List[T]()
> >
> > > I've seen this already (http://www.mailinglistarchive.com/html/
> > > [email protected]/2010-01/msg00404.html) but I'm not using
> > > named queries.
> >
> > > Is what I'm doing supported? Is there some way I can specify whatever
> > > extra info is required to support caching?
> >
> > > Thanks,
> > > Kent
> >
> > > --
> > > 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]<nhusers%[email protected]>
> <nhusers%[email protected]<nhusers%[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]<nhusers%[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.

Reply via email to