Hi All,
I'm just wondering if adding order to a criteria on a parent object column is possible. I know this is hard to understand so here is a sample.
Code:
public void TestSortingEmbeddedFields()
{
ISession s = DataFacade.GetSession();
ICriteria c = s.CreateCriteria(typeof(Child));
// Where parent is a relationship column
c.CreateAlias("Parent", "alias1");
// Line below works fine with alias
c.Add(Expression.Eq("alias1.Name", "TEST"));
// If I add the line below (Order) test fails.
// c.AddOrder(new Order("alias1.Name", true));
c.List();
}
When I run this code I get the following exception:
Code:
NHibernate.QueryException: could not resolve property:alias0.CompanyLayerName of :PicNet.RiskShield.DAL.RegisterRisk
at NHibernate.Persister.AbstractPropertyMapping.ToColumns(String alias, String propertyName)
at NHibernate.Expression.AbstractCriterion.GetColumns(ISessionFactoryImplementor factory, Type persistentClass, String property, String alias, IDictionary aliasClasses)
at NHibernate.Expression.Order.ToSqlString(ISessionFactoryImplementor sessionFactory, Type persistentClass, String alias)
at NHibernate.Loader.CriteriaLoader..ctor(IOuterJoinLoadable persister, ISessionFactoryImplementor factory, CriteriaImpl criteria)
at NHibernate.Impl.SessionImpl.Find(CriteriaImpl criteria)
at NHibernate.Impl.CriteriaImpl.List()
No sql was generated by this so I cannot include that in my post. And the exception did not appear in the hibernate logs did not provide any additional information (even in debug).
Cheers
Guido Tapia
Hibernate version:NHibernate 1.0.2 w/ SysCacheProvider Database: SQL Server[/code]