title: CriteriaBuilder radius calculation
body: <p>I am trying to calculate given lat/long with a distance, and only returning the rows that fall in that circular distance (Database has lat / long coordinates aswell). What I am unaware of is how I would do that. I am currently using Native SQL and have plain text with the haversine formula that calculates this, and if I am correct it is not possible to do the haversine formula with the CriteriaBuilder. However I want to have the same results using the CriteriaBuilder. I've tried using the hibernate-spatial dependency, but I am not getting it to work as I want it to. I have also followed tutorials such as this one.   </p>
  
  <p><a href="https://docs.jboss.org/hibernate/search/4.2/reference/en-US/html/spatial.html" rel="nofollow noreferrer">https://docs.jboss.org/hibernate/search/4.2/reference/en-US/html/spatial.html</a>  </p>
  
  <p>The database I am using is MySQL.<br>
  Hibernate version 4.3.10.  </p>
  
  <p>Also this tutorial didn't get me far <a href="https://stackoverflow.com/questions/18822133/using-jpa-criteria-api-and-hibernate-spatial-4-together">Using JPA Criteria Api and hibernate spatial 4 together</a></p>
  
  <p>So how would I build a CriteriaBuilder query with MySQL with a given lat / long and distance and retrieve only rows that fall in that area, comparing them to the lat / long coordinates stored in the database.  </p>