I'm trying to use the "select new [classname]" syntax to load some data into a data transfer class as described in the HQL section of the Hibernate manual but I can't seem to get it to work, so I must be missing a step somewhere along the line.
The select statement I'm using is:
Quote:
SELECT new TestClass(u.Id, u.Name, u.email) FROM User u
The error I'm getting is:
Quote:
class not found: TestClass [SELECT new TestClass(u.Id, u.Name, u.email) FROM Framework.Core.Entities.User u]
Stack Trace:
at NHibernate.Hql.SelectParser.Token(String token, QueryTranslator q)
at NHibernate.Hql.ClauseParser.Token(String token, QueryTranslator q)
at NHibernate.Hql.ClauseParser.End(QueryTranslator q)
at NHibernate.Hql.PreprocessingParser.End(QueryTranslator q)
at NHibernate.Hql.ParserHelper.Parse(IParser p, String text, String seperators, QueryTranslator q)
at NHibernate.Hql.QueryTranslator.Compile()
at NHibernate.Hql.QueryTranslator.Compile(ISessionFactoryImplementor factory, IDictionary replacements, Boolean scalar)
at NHibernate.Impl.SessionFactoryImpl.GetQuery(String queryString, Boolean shallow)
at NHibernate.Impl.SessionImpl.GetQueries(String query, Boolean scalar)
at NHibernate.Impl.SessionImpl.Find(String query, QueryParameters parameters)
at NHibernate.Impl.SessionImpl.Find(String query, Object[] values, IType[] types)
at NHibernate.Impl.SessionImpl.Find(String query)
When I had a look at the NHibernate code it seems like the class 'TestClass' needs to be loaded into the session factory. I've got it in the assembly - do I also need a mapping file? That doesn't seem to make sense... Does the class even have to be in the assembly?
Can someone get me on the right track?
Cheers,
Symon.