-->
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: SELECT COUNT(*) throws QueryException in NH 2.0
PostPosted: Mon Dec 29, 2008 12:32 pm 
Expert
Expert

Joined: Fri Oct 28, 2005 5:38 pm
Posts: 390
Location: Cedarburg, WI
Hibernate version: 2.0.1.GA

I am trying to upgrade from NH 1.2 to 2.0. We have some queries that do SELECT COUNT(*) that used to work, now ISession.CreateQuery throws
Code:
NHibernate.QueryException: undefined alias or unknown mapping: *


The exception is thrown at PathExpressionParser.cs: 145 in the Token() method.

The documentation on [url]http://nhforge.org/doc/nh/en/index.html#queryhql
[/url] section 12.5 says that COUNT(*) is supported.


Last edited by Nels_P_Olsen on Tue Dec 30, 2008 11:14 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 30, 2008 10:51 am 
Newbie

Joined: Thu Jul 03, 2008 11:16 am
Posts: 7
Hi!

I uses this and it works fine to me!

Int64 result = CurrentSession.CreateQuery("select count(*) from Lokal").UniqueResult<Int64>();

// SuperMattet


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 30, 2008 11:14 am 
Expert
Expert

Joined: Fri Oct 28, 2005 5:38 pm
Posts: 390
Location: Cedarburg, WI
Try using a more complicated query with aliases, e.g.
Code:
SELECT COUNT(*)
FROM A AS a
JOIN a.B AS b
...


Top
 Profile  
 
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.