Have you mapped Staff? If not, refer to section 14.1.5 on the link you posted.

/Oskar


2010/4/22 Ex_Soft <[email protected]>:
> Hi!!!
>
> http://knol.google.com/k/fabio-maulo/nhibernate-chapter-14/1nr4enxv3dpeq/17#
>
> using System;
> using System.Collections.Generic;
> using System.Reflection;
> using NHibernate;
> using NHibernate.Cfg;
>
> namespace TestXIII
> {
>        public class Staff
>        {
>                int _ID;
>                string _Name;
>
>                public virtual int ID
>                {
>                        get { return _ID; }
>                        set { _ID = value; }
>                }
>
>                public virtual string Name
>                {
>                        get { return _Name; }
>                        set { _Name = value; }
>                }
>        }
>
>        class Program
>        {
>                static ISessionFactory
>                        SessionFactory;
>
>                static void Main(string[] args)
>                {
>                        try
>                        {
>                                using (ISession session = OpenSession())
>                                {
>                                        ISQLQuery
>                                                query = 
> session.CreateSQLQuery("select ID, Name from
> Staff").AddEntity(typeof(Staff));
>
>                                        IList<Staff>
>                                                _List_Staff_ = 
> query.List<Staff>();
>                                }
>                        }
>                        catch (Exception e)
>                        {
>                                Console.WriteLine(e);
>                        }
>                }
>
>                static ISession OpenSession()
>                {
>                        if (SessionFactory == null)
>                        {
>                                Configuration
>                                        configuration = new Configuration();
>
>                                
> configuration.AddAssembly(Assembly.GetCallingAssembly());
>                                SessionFactory = 
> configuration.BuildSessionFactory();
>                        }
>
>                        return SessionFactory.OpenSession();
>                }
>        }
> }
>
> NHibernate.MappingException: No persister for: TestXIII.Staff
>   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.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]()
>
> Why???
>
> (P.S. NHibernate.dll ver. 2.1.2.4000 (NHibernate-2.1.2.GA (http://
> sourceforge.net/projects/nhibernate/files/NHibernate/2.1.2GA/
> NHibernate-2.1.2.GA-bin.zip/download)))
>
> --
> 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.
>
>

-- 
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