-->
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: Complex calcs with latitude/longitude query in HQL
PostPosted: Tue Nov 08, 2005 3:08 pm 
Newbie

Joined: Wed Feb 09, 2005 11:15 am
Posts: 7
Location: Argentina
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.0

Name and version of the database you are using: MSSQLServer

Hi people again:
I am new in hibernate and I need to make the following query:

I need to execute this query but i dont know how to obtain the complex calc ("acos(sin(radians()..."). I see the <formula> tag in hibernate docs but i not understood, i not sure if this is what I need.

This is the query:
it is for calculating the agents whom there are in zip and certain radius.

/*******************************************************************************
SELECT agent.agtID, agtNameLastFirst, agtCompany, agtWorkPhone, agtStreetCity,
agtStreetState, isnull(a.empID, -1) AS mktrID

FROM agt_datAgent as agent
INNER JOIN con_qrynamesFormatted as namesFormatted
ON agent.agtID = namesFormatted.agtID

INNER JOIN

(SELECT zips.zip, zips.city, zips.state, acos(sin(radians(base.latitude))*sin(radians(zips.latitude))+cos(radians(base.latitude))*cos(radians(zips.latitude))*cos(radians(zips.longitude)-radians(base.longitude))) * 3963 as distance

FROM m_refZipCity as zips,

(SELECT state, longitude, latitude
FROM m_refZipCity
WHERE zip = "zip") AS base

WHERE acos(sin(radians(base.latitude))*sin(radians(zips.latitude))+cos(radians(base.latitude))*cos(radians(zips.latitude))*cos(radians(zips.longitude)-radians(base.longitude))) * 3963 <= "radius") AS filter

ON agent.agtStreetZip = filter.zip
/*******************************************************************************
where:
zip = an imput text of my web form.
radius: = an imput text of my web form.

please, I need that they orient to me since to make this query in HQL


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 08, 2005 3:27 pm 
Senior
Senior

Joined: Mon Apr 04, 2005 8:04 am
Posts: 128
Location: Manchester, NH USA
This exact question was just asked (concerning Great Circle distance, even!), and had several good answers given, within the past few days:

http://forum.hibernate.org/viewtopic.php?t=948930&highlight=acos

Hope that helps.


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.