BoardRepository
페이지 정보
본문
package web.repository;
import java.util.List;
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.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import jakarta.transaction.Transactional;
import web.domain.Board;
public interface BoardRepository extends JpaRepository<Board, Long>{
//List 타입 추가
List<Board> findByBnoBetweenOrderByBnoDesc(Integer from, Integer to);
//쿼리 메서드와 Pageable 결합
Page<Board> findByBnoBetween(Integer from, Integer to, Pageable pageable);
//deleteBy로 시작하는 삭제처리
void deleteBoardByBnoLessThan(Integer bno);
@Query("select b from Board b order by b.bno desc") //Board : 클래스명
List<Board> list();
@Transactional
@Modifying
@Query("update Board b set b.title = :title where b.bno = :bno")
int updateBoard(@Param("bno") Integer bno, @Param("title") String title); //변수 처리
@Transactional
@Modifying
@Query("update Board b set b.title = :#{#param.title} where b.bno = :#{#param.bno}")
int updateBoard2(@Param("param") Board board); //객체 처리
}
- 이전글② @Query 24.06.15
- 다음글BoardRepositoryQueryTests2 24.06.16
댓글목록
등록된 댓글이 없습니다.