-->
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: SqlProjection with joined-subclass generates the wrong alias
PostPosted: Tue May 18, 2010 2:43 am 
Newbie

Joined: Fri Mar 17, 2006 5:23 pm
Posts: 6
I am attempting to execute the following NH query:
Code:
session.CreateCriteria<Derived>()
   .SetProjection(
      Projections.SqlProjection(
         "case when {alias}.Name between 'A' and 'N' then 'A-M' else 'Other' end as range",
         new[] { "range" },
         new[] { NHibernateUtil.String }))
   .List();
My Derived class is mapped as a <joined-subclass> of Base. The {alias}.Name property is implemented in the Base class. This generates the following incorrect SQL:
Code:
SELECT
   case
      when this_.Name between 'A' and 'N' then 'A-M'
      else 'Other'
   end as range
FROM Derived this_
inner join Base this_1_ on this_.BaseFK=this_1_.PK
Note that this_.Name should actually be this_1_.Name. Is this a bug, or am I doing something wrong?

-- Brian


Top
 Profile  
 
 Post subject: Re: SqlProjection with joined-subclass generates the wrong alias
PostPosted: Tue Mar 15, 2011 8:19 am 
Newbie

Joined: Tue Mar 15, 2011 8:16 am
Posts: 1
Was this question answered?
I am running into the same problem too.
Can anyone help?

Thanks in advance!


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.