| Author |
Complex math in HQL
|
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56549
|
posted

0
|
I have a table named LOCATIONS mapped to an entity named Location.
The SQL that works for me is as follows:
select ZipCode,sqrt( square(:latitudeValue - Latitude) + square(:longitudeValue - Longitude)) as distance from LOCATIONS order by distance
which, when I limit the returned list to single value, gives me the record I need.
What's the HQL equivalent? I'm just used to referencing entity properties...
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
David O'Meara
Rancher
Joined: Mar 06, 2001
Posts: 13459
|
posted

1
|
|
just as an aside, it may be easier on the database (but check first) if you omit the sqrt in the SQL/HQL and apply it to the code afterwards.
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56549
|
posted

0
|
|
DB is SQL Server (if it makes nay difference).
|
 |
Mark Spritzler
ranger
Sheriff
Joined: Feb 05, 2001
Posts: 17243
|
posted

0
|
Sorry, I posted a possible HQL in your other thread.
You can always also just stick with the SQL.
I like the HQL version though. Check your other thread.
Thanks
Mark
|
Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56549
|
posted

0
|
|
Thanks Mark. I'll close this one to prevent duplication.
|
 |
 |
|
|
subject: Complex math in HQL
|
|
|