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