title: HQL : Distance calculation between two locations?
body: <p>I have a table <code>Restaurants</code> which stores the details of restaurants including <code>Latitude</code> and <code>Longitude</code> .now i have to sort out the records from DB those within <code>20 Kilo Meter</code> of the given <code>Lat/Lon</code> input values.</p>
  
  <p>I am using RESTful web-service with hibernate.</p>
  
  <p><strong><em>Entity Class</em></strong></p>
  
  <pre><code>@Entity
  @Table(name = "restaurants")
  public class Restaurants implements Serializable {
  
      private static final long serialVersionUID = 1L;
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      @Column(name = "restaurant_id")
      private int restaurantId;
  
      @Column(name = "restaurant_name")
      private String restaurantName;
  
      @Column(name = "category_id")
      private Integer categoryId;
  
      @Column(name = "image_url")
      private String imageUrl;
  
      private Float longitude;
  
      private Float latitude;
  
      @Column(name = "contact_name")
      private String contactName;
  
      @Column(name = "primary_phone")
      private String primaryPhone;
  
      @Column(name = "secondary_phone")
      private String secondaryPhone;
  
      private String fax;
  
      private String address1;
  
      private String address2;
  
      //Getters and Setters
  
  } 
  </code></pre>
  
  <p>I have surfed but couldn't find any satisfying answer.is it preferable <code>between</code> operation to find out the difference between <code>Lat/Long</code>.or do i use <code>Criteria</code> ? Any one please provide me an answer .?      </p>