Location 데이터를 넣다가 자꾸 이상하게 매핑되서 문제점을 발견했다.
@Getter
@Embeddable
public class Location {
private double latitude;
private double longitude;
protected Location() {}
public Location(double latitude, double longitude) {
this.latitude = latitude;
this.longitude = longitude;
}
}
// MyBatis
ST_Distance_Sphere(
p.location,
ST_SRID(POINT(#{location.longitude}, #{location.latitude}), 4326)
) as distance,
자꾸 Location.longitude, latitude로 설정했는데
latitue가 longitude자리로 들어가서
mybatis 동작원리를 이해해보니
파라미터 이름 매핑이 아닌 필드 선언 순서 매핑이였다..
#{location.longitude} 이게 getLogitude() 를 호출하는게 아니다.
삽질을 좀 했는데 다시는 이런 실수를 하지 않을 것같다...
'Back-End > Spring' 카테고리의 다른 글
| 프로젝트 중 잘못된 테스트 바로잡기 (2) | 2025.07.08 |
|---|---|
| 테스트에서 영속화 (0) | 2025.06.30 |
| detached entity passed to persist (0) | 2025.06.30 |
| OIDC로 소셜 로그인 구현 [Spring Boot] (2) | 2025.06.14 |
| filter 코드 리팩토링 해보기 (0) | 2025.04.07 |