-->
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: Exception: "No Dialect mapping for JDBC type: -1"
PostPosted: Wed Jul 18, 2007 10:58 am 
Newbie

Joined: Wed Jul 18, 2007 10:49 am
Posts: 2
Hi,

I'm a relatively new user to hibernate.

I'm using hibernate 3 and mysql 4.1.22. I'm trying to execute the following sql query that would get me a list of cities from my database ordered by distance to an input [latitude, longtitude].

To do this, I created a subselect and use mysql functions to do the calculations.

Code:
            SQLQuery q = session.createSQLQuery("select *, sqrt(pow(a, 2) + pow(b, 2)) as distance from (select *, abs(:latitude - latitude) as a, abs(:longitude - longitude) as b from user where activated = true and site_id = :site_id) as temp order by distance");
            q.setParameter("site_id", site.getId());
            q.setParameter("latitude", latitude);
            q.setParameter("longitude", longitude);
            return q.list();


However, I get the following exception on q.list():
Code:
org.hibernate.MappingException: No Dialect mapping for JDBC type: -1
   at org.hibernate.dialect.TypeNames.get(TypeNames.java:56)
   at org.hibernate.dialect.TypeNames.get(TypeNames.java:81)
   at org.hibernate.dialect.Dialect.getHibernateTypeName(Dialect.java:192)
   at org.hibernate.loader.custom.CustomLoader.getHibernateType(CustomLoader.java:170)
   at org.hibernate.loader.custom.CustomLoader.autoDiscoverTypes(CustomLoader.java:138)
   at org.hibernate.loader.Loader.getResultSet(Loader.java:1678)


What do I need to change to make this work?

Thanks!


Top
 Profile  
 
 Post subject: Re: Exception: "No Dialect mapping for JDBC type: -1&qu
PostPosted: Wed Jul 18, 2007 4:27 pm 
Newbie

Joined: Wed Jul 18, 2007 10:49 am
Posts: 2
jvdb wrote:

Code:
            SQLQuery q = session.createSQLQuery("select *, sqrt(pow(a, 2) + pow(b, 2)) as distance from (select *, abs(:latitude - latitude) as a, abs(:longitude - longitude) as b from user where activated = true and site_id = :site_id) as temp order by distance");



I solved it myself by transforming it to a HQL:

Code:
from User user where activated = true and site_id = :site_id order by sqrt((abs(:latitude - latitude)*abs(:latitude - latitude)) + (abs(:longitude - longitude)*abs(:longitude - longitude)))


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 03, 2007 6:31 am 
Beginner
Beginner

Joined: Tue Jan 18, 2005 9:37 am
Posts: 29
Location: The Netherlands
This might help you. http://forum.hibernate.org/viewtopic.ph ... 78#2366178


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 03, 2007 8:47 am 
Newbie

Joined: Mon Oct 01, 2007 8:59 am
Posts: 18
you can try first query by writing this code in hibernate.cfn.xml file it may resolve ur error "No Dialect mapping for JDBC type: -1"

<property name="dialect">org.hibernate.dialect.MySQLDialect</property>


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.