mrsnospam wrote:
select acos(sin(:lat) * sin(biz.address.latitude/57.29) + cos(:lat) * cos(biz.address.latitude/57.29) * cos(biz.address.longitude/57.29 - :lon) ) * 3956 as distance, biz from Business biz group by biz.name having distance > 4
Hibernate: select acos(sin(?)*sin(address1_.latitude/57.29)+cos(?)*cos(address1_.latitude/57.29)*cos(address1_.longitude/57.29-?))*3956 as col_0_0_, business0_.biz_id as col_1_0_, business0_.biz_id as biz1_1_, business0_.biz_name as biz2_1_, business0_.distance as distance1_, business0_.current_rating as current4_1_, business0_.num_ratings as num5_1_, business0_.num_positive as num6_1_, business0_.num_negative as num7_1_, business0_.status_cd as status8_1_, business0_.started_yr as started9_1_, business0_.address_id as address10_1_ from business business0_, address address1_ where business0_.address_id=address1_.address_id group by business0_.biz_name having distance>4 limit ?
0 elements
took 1057 millis
Looks to me like Hibernate's SQL munging is renaming your "distance" column to "col_0_0_". It would be a terrible hack, but would it work to change your HQL to this?
select acos(sin(:lat) * sin(biz.address.latitude/57.29) + cos(:lat) * cos(biz.address.latitude/57.29) * cos(biz.address.longitude/57.29 - :lon) ) * 3956
as col_0_0_, biz from Business biz group by biz.name having
col_0_0_ > 4
It's terrible, but sometimes terrible things work :-) Of course this really does sound like a bug in Hibernate, in which case you should JIRA it.
Cheers! (And if this helped, please rate me ;-)
Rob