Thanks for the reply Fabio. I tried what you said (see mapping below)
and got this error:
NHibernate.Loader.Custom.Sql.SQLCustomQuery: 2010-01-18 23:15:25,456
[1] DEBUG (NHibernate.Loader.Custom.Sql.SQLCustomQuery:0) - starting
processing of sql query [exec getUserSecurity :PersonId]
NHibernate.Impl.SessionFactoryImpl: 2010-01-18 23:15:25,472 [1] ERROR
(NHibernate.Impl.SessionFactoryImpl:0) - Error in named query:
GetUserSecurity
NHibernate.MappingException: No persister for: Security
at NHibernate.Impl.SessionFactoryImpl.GetEntityPersister(String
entityName)
at
NHibernate.Loader.Custom.Sql.SQLQueryReturnProcessor.GetSQLLoadable
(String entityName)
at
NHibernate.Loader.Custom.Sql.SQLQueryReturnProcessor.ProcessRootReturn
(NativeSQLQueryRootReturn rootReturn)
at
NHibernate.Loader.Custom.Sql.SQLQueryReturnProcessor.ProcessReturn
(INativeSQLQueryReturn rtn)
at NHibernate.Loader.Custom.Sql.SQLQueryReturnProcessor.Process()
at NHibernate.Loader.Custom.Sql.SQLCustomQuery..ctor
(INativeSQLQueryReturn[] queryReturns, String sqlQuery, ICollection`1
additionalQuerySpaces, ISessionFactoryImplementor factory)
at NHibernate.Engine.Query.NativeSQLQueryPlan..ctor
(NativeSQLQuerySpecification specification, ISessionFactoryImplementor
factory)
at NHibernate.Engine.Query.QueryPlanCache.GetNativeSQLQueryPlan
(NativeSQLQuerySpecification spec)
at NHibernate.Impl.SessionFactoryImpl.CheckNamedQueries()
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<sql-query name="GetUserSecurity">
<return class="Security, Security">
<return-property column="code" name="Code" />
<return-property column="permission" name ="Permission" />
</return>
exec getUserSecurity :UserId
</sql-query>
</hibernate-mapping>
On Jan 18, 5:46 pm, Fabio Maulo <[email protected]> wrote:
> have a look to the intellisense. The <sql-query> has some others info
> needed.. as <return....
>
> 2010/1/18 nabils <[email protected]>
>
>
>
>
>
> > I think I have encountered a bug. I'm using v 2.1.2.4000 with the
> > following mapping:
>
> > <?xml version="1.0" encoding="utf-8" ?>
> > <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
> > <sql-query name="GetUserSecurity">
> > exec getUserSecurity :UserId
> > </sql-query>
> > </hibernate-mapping>
>
> > This stored procedure returns two columns.
>
> > When I call the following code with setCacheable(true) everything
> > works fine but as soon as I set it to true I get the
> > IndexOutOfRangeException (see full exception details below).
>
> > using (var session = sessionProvider.Create())
> > using (var tx = session.BeginTransaction())
> > {
> > security= session.GetNamedQuery("GetUserSecurity")
> > .SetParameter("UserId", 1234)
> > //.SetCacheable(true)
> > .List();
>
> > tx.Commit();
> > }
>
> > Exception details:
> > System.IndexOutOfRangeException was unhandled by user code
> > Message="Index was outside the bounds of the array."
> > Source="NHibernate"
> > StackTrace:
> > 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]()
> > at Application_OnAuthenticateRequest(Object sender, EventArgs
> > e)
> > at
>
> > System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplicatio
> > n.IExecutionStep.Execute
> > ()
> > at System.Web.HttpApplication.ExecuteStep(IExecutionStep step,
> > Boolean& completedSynchronously)
> > InnerException:
>
> > Thanks in advance
>
> > --
> > 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.
>
> --
> Fabio Maulo
--
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.