Data truncation: Truncated incorrect DOUBLE value: '' 오류 해결

소만이·2024년 7월 9일
0
post-thumbnail

jpa로 delete 쿼리를 날리는 와중에 Data truncation: Truncated incorrect DOUBLE value: 'NORMAL' 이런 오류가 떴다. (여기서 'NORMAL' 은 데이터 보낸 Enum값이다.)
db에도 데이터형식이 잘 맞춰 들어갔는데 왜 자꾸 데이터 형식이 맞지 않는다고 뜰까해서
데이터 보내는 곳에 "" 도 붙여보고 where 조건에 and 대신에 , 쉼표도 붙여봤으나 에러는 똑같았다.

@Modifying
    @Query(
        "DELETE FROM content_tag WHERE content_id in (:contentId) and content_tag_type = :contentTagType ",
        nativeQuery = true
    )
    fun deleteAllByContentIdAndContentTagType(contentId: Long, contentTagType: ContentTagType)

ContentTagType 은 Enum Class였는데 해당 Enum을 String 값으로 못 가져오는 것 같아
보내는 곳에서는 contentTagType.NORMAL.name으로 보냈고,
받는 이 곳에서는 ContentTagType이 아닌 String값으로 받는 것으로 고쳤다.

@Modifying
    @Query(
        "DELETE FROM content_tag WHERE content_id in (:contentId) and content_tag_type = :contentTagType ",
        nativeQuery = true
    )
    fun deleteAllByContentIdAndContentTagType(contentId: Long, contentTagType: String)

이렇게 String값으로 받으니 해결이 되었다!

0개의 댓글