-->
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.  [ 3 posts ] 
Author Message
 Post subject: SQL Server Sort Error
PostPosted: Tue Nov 01, 2005 7:13 pm 
I've been using SQL Server for almost a decade now and I've never seen this error before... The SQL generated by NHIbernate is valid, and should work, but SQL Server for some reason just doesn't like it.

The HQL is:

Code:
SELECT Product FROM Product AS Product LEFT OUTER JOIN Product.MainCategory AS Category INNER JOIN Product.Manufacturer AS Manufacturer ORDER BY Manufacturer.Name, Category.FullName, Product.Name

The generated SQL is:

Code:
select top 5
product0_.Uid as Uid,
product0_.AvailableOn as Availab11_,
product0_.Name as Name,
product0_.Price as Price,
product0_.Manufacturer as Manufact6_,
product0_.ModelNumber as ModelNum7_,
product0_.ImageThumbnailUrl as ImageTh14_,
product0_.MainCategory as MainCate5_,
product0_.Version as Version,
product0_.Weight as Weight,
product0_.Description as Descript4_,
product0_.ImageUrl as ImageUrl,
product0_.Notes as Notes,
product0_.Dimension as Dimension,
product0_.Url as Url
from SevenCamels_Applications_ScrappyCamel_BusinessObjects_Product product0_
left outer join SevenCamels_Applications_ScrappyCamel_BusinessObjects_Category category1_
on product0_.MainCategory=category1_.Uid
inner join SevenCamels_Applications_ScrappyCamel_BusinessObjects_Manufacturer manufactur2_
on product0_.Manufacturer=manufactur2_.Uid
order by  manufactur2_.Name , category1_.FullName , product0_.Name

The error thrown by SQL Server is:

"A column has been specified more than once in the order by list. Columns in the order by list must be unique."

I believe it's because the product0_.Name column has been given the Name alias. SQL Server sees two Name columns in the ORDER BY clause and freaks out, even though they're both qualified and different. If I take out the alias for the product0_.Name column, the SQL works fine (just in Query Analyzer). It's a bug that's been noted before in the LLBLGen forums. Has anyone seen it before and managed to come up with a fix or workaround?


Top
  
 
 Post subject:
PostPosted: Thu Nov 03, 2005 12:01 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Please enter this as a bug in JIRA and we'll see what we can do. No promises, though...


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 06, 2005 11:40 pm 
It's been entered into JIRA, along with an example project that duplicates the error. I was actually working with .NET 2.0 when I found the error, but I've written the example project for .NET 1.1.

http://jira.nhibernate.org/browse/NH-447

I didn't mention before that I was using SQL Server 2000. I might try it with SQL Server 2005 and see if the same error shows up.


Top
  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.