Skip to content

Instantly share code, notes, and snippets.

@roharon
Last active July 24, 2020 08:24
Show Gist options
  • Save roharon/f783187bcc280157962739d017d4a5ed to your computer and use it in GitHub Desktop.
Save roharon/f783187bcc280157962739d017d4a5ed to your computer and use it in GitHub Desktop.
package com.aaronroh.gmoney.domain.store;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
public interface StoreRepository extends JpaRepository<Store, Long> {
@Query(
value = "SELECT * FROM store s WHERE s.sigoon = :sigoon and earth_distance(" +
"ll_to_earth(CAST(s.latitude as float), CAST(s.longitude as float))," +
"ll_to_earth(:latitude, :longitude)) < :radius",
nativeQuery = true)
Page<Store> findBySigoonAndEarthDistance(Pageable pageable, @Param("sigoon") String sigoon, @Param("latitude") Float latitude,
@Param("longitude") Float longitude, @Param("radius") Integer radius);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment