0

Possible Duplicate:
How to write NamedQuery haversine formula in NamedQuery?

I want to run below namedquery:

List<Object> result= em.createQuery("select sum(u.mlatitude) from UserGpsLocation u").getResultList();
return result.get(0);

Can anyone help me and tell me what's wrong with it?

Community
  • 1
  • 1
user1522804
  • 149
  • 2
  • 11
  • This code is written as web service function and when I try to run it from browser it gives me 500 internal server error. – user1522804 Jul 26 '12 at 20:32
  • Infact my main aim is to run below Query: set @orig_lat=37.334542; set @orig_lon=-121.890821; set @dist=10; select *, 3956*2*ASIN(SQRT(POWER(SIN((@orig_lat-abs(mlatitude))*pi()/180/2),2) +COS(@orig_lat*pi()/180) * COS(abs(mlatitude)* pi()/180) *POWER(SIN((@orig_lon -mlogitude)* pi()/180/2),2))) as distance from user_gps_location having distance < @dist ORDER BY distance but I got an error in it. – user1522804 Jul 26 '12 at 20:34
  • Here is the link where I actual mention the whole problem. http://stackoverflow.com/questions/11657256/how-to-write-namedquery-haversine-formula-in-namedquery – user1522804 Jul 26 '12 at 20:36
  • why create another question when you already have one along the same lines? – Sujay Jul 26 '12 at 20:39
  • Infact I was not getting solution of that so now I am trying from simple query which calculates sum so if I get the solution of this then may be I will go further for other parameters. – user1522804 Jul 26 '12 at 20:52

0 Answers0