-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Is it possible to add Order on a parent object column?
PostPosted: Fri Feb 24, 2006 12:52 am 
Newbie

Joined: Sat Jun 11, 2005 1:56 am
Posts: 19
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]


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 24, 2006 8:19 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
No, it's not possible currently.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.