JpaRepository에서 @Query 어노테이션을 이용해 DELETE문을 작성할 때 발생하는 에러
UPDATE, DELETE 쿼리에는 @Modifying, @Transactional 어노테이션을 모두 붙여야한다.
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;
@Modifying
@Transactional
@Query("DELETE " +
" FROM Comment " +
" WHERE commentId = :commentId " +
" AND boardId = :boardId")
void deleteByCommentIdAndBoardId(Long commentId, Long boardId);
'웹 개발 > 오류' 카테고리의 다른 글
[Javascript] JSP에서 백틱(`)의 템플릿 문자열을 사용하지 못할 때 (0) | 2023.05.09 |
---|---|
Spring Boot와 MariaDB 연동 후 java.util.concurrentmodificationexception: null (0) | 2023.03.27 |
Type [java.lang.String] is not valid for option items (0) | 2023.02.10 |
Spring - 요청 데이터로 JSON을 보냈을 때 상태코드 415 (0) | 2023.02.02 |
Spring - MultipartFilter 설정 후 한글이 깨지는 현상 (0) | 2023.01.30 |