Hibernate version: 3.1
Name and version of the database you are using: mysql 5
I have this great hql below. I want to also capture the distance being calculated as well. Currently the resultset is a Business object. Is there a simple way to do a alias or something and have the distance set on my Business object as well?
String hql = "from Business biz where biz.name like :criteria and "+
" acos( " +
" sin(:lat) * sin(biz.address.latitude) + " +
" cos(:lat) * cos(biz.address.latitude) * " +
" cos(biz.address.longitude - :lon) " +
" ) * 3956 < :distance order by biz.currentRating desc";
Query query = session.createQuery(hql)
.setInteger("distance", radius)
.setString("criteria", likeCriteria)
.setDouble("lat", targetZip.getLatitude())
.setDouble("lon", targetZip.getLongitude())
.setFirstResult(offset)
.setMaxResults(RESULTS_PER_PAGE);
|