-->
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: isNull in select clause: undefined alias?
PostPosted: Wed Mar 10, 2004 12:24 pm 
Beginner
Beginner

Joined: Tue Oct 28, 2003 12:09 pm
Posts: 46
I have this query which works great returning arrays of objects
{ [topic, hitsory], [topic, history] etc }

Code:
select topic, history from Topic as topic left outer join topic.topicHistories as history where topic.course = ? and (history.user= ? or history is null) group by topic, history"


As specified, the history object can be null. I tried to change the query to be:

Code:
select topic, isNull(history.postsViewed, 0) from Topic as topic left outer join topic.topicHistories as history where topic.course = ? and (history.user= ? or history is null) group by topic, history.postsViewed"


and hibernate complains that isNull is an undefined alias.

I've plowed through the docs looking for examples of isNull in the select clause without luck. All examples seem to use isNull in the where clause.

Anyone see any obvious stupidities on my part? I've worked around this by checking for null in the results and substituting a zero, but I don't know why my isNull attempt failed.

I'm running on sqlserver... *ick*

I think I'm using hibernate 2.1.1 (Is there an easy way to tell if all you have is the hibernate2.jar left of the download?) but it could be 2.1.2.

-mp


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 10, 2004 12:26 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
One argument sql functions in the select clause are not supported without registering with the dialect. Two argument sql functions in the select clause are not supported at all.


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.