-->
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: Hibernate createSQLQuery Help
PostPosted: Tue Jan 23, 2007 12:58 pm 
Newbie

Joined: Wed Jan 03, 2007 7:28 pm
Posts: 3
Below is a SQL statement that works anywhere except when I use it through hibernate. Can anyone see anything that I am doing wrong or any suggestions.

Call: (Double) getSession().createSQLQuery(AVG_DAILY_FILE_SIZE).uniqueResult();

Hibernate:
/* dynamic native SQL query */ select
avg(avg_daily_file_size / (select
count(distinct date)
from
Issue i,
File f
where
i.issue_id = f.issue_id)) as total
from
(select
sum(f.file_size) as avg_daily_file_size
from
Issue i,
File f
where
i.issue_id = f.issue_id
group by
i.date) as total_a

Error:
ERROR [JDBCExceptionReporter] Column '' not found.
ERROR org.hibernate.exception.SQLGrammarException: could not execute query


Thanks in advance for your help.


Top
 Profile  
 
 Post subject: Fixed
PostPosted: Tue Jan 23, 2007 2:37 pm 
Newbie

Joined: Wed Jan 03, 2007 7:28 pm
Posts: 3
I have fixed my own problem by adding the following:

size = (Double) getSession().createSQLQuery(AVG_DAILY_FILE_SIZE).addScalar("total", Hibernate.DOUBLE).uniqueResult();

Thanks.


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.