Last active
July 24, 2020 08:24
-
-
Save roharon/f783187bcc280157962739d017d4a5ed to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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