-->
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: Query Problems
PostPosted: Wed Jan 03, 2007 7:38 pm 
Newbie

Joined: Wed Jan 03, 2007 7:28 pm
Posts: 3
I am running into a problem trying to execute a query using Hibernate 3 on MySQL. I have not been using hibernate for all that long.

First off, does everything have to be mapped if I use the getHibernateTemplate to execute a query?

My query is the following:

select avg(avg_daily_file_size / (select count(distinct date) as total_days from issue i, `file` f
where i.issue_id = f.issue_id)) 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;

This works pefectly fine if I run it from MySQL itself.

I am calling getHibernateTemplate().findByNamedQuery("fileSize"); to execute it.

I have the named query in a file and below is the enitre contents of the file:


<hibernate-mapping>
<sql-query name="fileSize">
<![CDATA[
select avg(avg_daily_file_size / (select count(distinct date) as total_days from issue i, `file` f
where i.issue_id = f.issue_id)) 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
]]>
</sql-query>
</hibernate-mapping>

I get the following, and it is very aggrevating: org.springframework.orm.hibernate3.HibernateSystemException: No Dialect mapping for JDBC type: 3;

I do have my dialect set to org.hibernate.dialect.MySQLMyISAMDialect

Is there a better way of doing this? Can I just execute a query and return a Double or something?

I am doing this against MySQL but I will be moving it to Oracle for prod.

Thanks in advance for any help.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 03, 2007 9:55 pm 
Regular
Regular

Joined: Thu Jul 29, 2004 11:55 pm
Posts: 75
This is probably not the best answer for you, but if you look at this forum entry, you can see the problem.

http://forum.hibernate.org/viewtopic.ph ... d6709fa6ad

The basic problem is that the hibernate dialect does not have a column type mapped. I am not too familair with MySQL specific dialect (and maybe sql advanced features), but I would think your issue is with the 'file' syntax. I am assuming this is some sort of type. If this is correct, did you try running the query as a native sql query instead of a named query? I am not sure if the spring template does this or not (since I don't use spring).


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.