본문 바로가기
유용한 사이트 및 정보

Repository 네이티브 쿼리 예제

by pyogowoon 2023. 1. 19.

public interface ReplyRepository extends JpaRepository<Reply, Integer> {

    @Modifying  // int만 반환 가능함
    @Query(value="INSERT INTO reply(userId, boardId, content, createDate) values(?1, ?2, ?3,now())", nativeQuery = true)
    int mSave(int userId, int boardId, String content);

}

댓글