-->
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.  [ 5 posts ] 
Author Message
 Post subject: Setting column aliases ( " , expected in SELECT ...&quo
PostPosted: Wed Dec 29, 2004 11:43 am 
Newbie

Joined: Mon Jun 14, 2004 5:16 pm
Posts: 16
Location: New York
Hibernate version: 2.1
Name and version of the database you are using: MySQL 4.0.12

I'm trying to write the following sql in hibernate:

Code:
select count(*) as total , category from tbl_search_tracking group by category order by total


I tried the following:

Code:
select count(*) as total, st.category from SearchTrack st where [condition]
group by st.category order by total



and it generated the following error:

Code:
com.emirca.touch.module.business.model.BusinessManager runPopularSearchReportWARNING: Error running 'search number per portal' , expected in SELECT [select new com.emirca.touch.module.business.model.SearchTrack(count(*) alias tot, st.category) from com.emirca.touch.module.business.model.SearchTrack st  where st.searchDate >= :fromDate and  st.searchDate <= :toDate  and st.portalName = :portal  group by st.category ]


Is setting column aliases not possible in Hibernate?

Thanks,
Cagan


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 29, 2004 11:49 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
It is not possible and not needed

_________________
Emmanuel


Top
 Profile  
 
 Post subject: Setting column aliases
PostPosted: Thu Dec 30, 2004 9:17 am 
Newbie

Joined: Mon Jun 14, 2004 5:16 pm
Posts: 16
Location: New York
I understand that it's not supported by Hibernate but why 'not needed'?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 30, 2004 11:20 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I've never seen any use case for it :)
Seriously, the Hibernate PAI are simple enough, there is no need for alias IMO

_________________
Emmanuel


Top
 Profile  
 
 Post subject: Setting column aliases
PostPosted: Thu Dec 30, 2004 11:22 am 
Newbie

Joined: Mon Jun 14, 2004 5:16 pm
Posts: 16
Location: New York
Emmanuel,

Given my query, how can I then write in HQL to order by count(*)?

Thanks
Cagan


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