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.  [ 4 posts ] 
Author Message
 Post subject: object[] nor returned with multiple scalar enteties
PostPosted: Tue Apr 03, 2007 3:19 am 
Newbie

Joined: Thu Aug 10, 2006 10:08 pm
Posts: 12
Hibernate version:
1.0.3.0

Code between sessionFactory.openSession() and session.close():

String query =
"SELECT sum(Amount) , count(*) "+
"From Transaction t ";

IQuery q = Persistor.getSession().CreateQuery(query);
q.SetParameter("Batch",b);
IEnumerable results = q.Enumerable();
foreach(object[] o in results)
{
theSet.Add(o);
}

Full stack trace of any exception that occurs:
au.com.compassion.eftrerun.readWriteTest.getTransactionsTest : System.InvalidCastException : Specified cast is not valid.


Ok so the problem is when i issue a Query with multiple scalar Queries i get only one result returned in the IEnumerable object (the documentation says it should return an object[], this seems to be incorect) a Bug or is my code is wrong.

Thanks for your help


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 03, 2007 4:07 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
And what is the type of the result, then?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 03, 2007 7:07 pm 
Newbie

Joined: Thu Aug 10, 2006 10:08 pm
Posts: 12
a single System.Int32 has been returned, it has the first Agregate function value. (acording to the NHibernate.Impl.EnumerableImpl object)

however this is also incoreect as it should be returning a float or Decimal type. as the sum is summing a money SQL type

the statement that hits the MSSQL server is
Code:
exec sp_executesql N'select sum(Amount) as x0_0_, count(*) as x1_0_ from EFTTransaction transactio0_'


When i run this in Query analyser it returns corectly.

1325872.5000 22769


thanks for your help


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 09, 2007 8:58 pm 
Newbie

Joined: Thu Aug 10, 2006 10:08 pm
Posts: 12
interestingly i changed the Query to

Code:
   "SELECT  sum(t.Amount) , count(t) "+
   "From Transaction t ";

and everything worked fine......

The query is exactly the same in SQL Profiler.

anyway problem solved


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