BoardRepositoryTest > SPRING_DATA_JPA

본문 바로가기

사이트 내 전체검색

뒤로가기 SPRING_DATA_JPA

BoardRepositoryTest

페이지 정보

작성자 관리자 작성일 24-06-17 11:01 조회 865 댓글 0

본문

package web.repository;


import java.util.Optional;

import java.util.stream.IntStream;


import org.junit.jupiter.api.Test;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.boot.test.context.SpringBootTest;

import org.springframework.data.domain.Page;

import org.springframework.data.domain.PageRequest;

import org.springframework.data.domain.Pageable;

import org.springframework.data.domain.Sort;


import jakarta.transaction.Transactional;

import lombok.extern.log4j.Log4j2;

import web.domain.Board;


@SpringBootTest

@Log4j2

public class BoardRepositoryTest {


@Autowired

private BoardRepository boardRepository;


@Test

public void testSearchAll() {

String[] types = {"t","c","w"};


String keyword = "1";


// 1 page order by bno desc

Pageable pageable = PageRequest.of(0, 10, Sort.by("bno").descending());


Page<Board> result = boardRepository.searchAll(types, keyword, pageable);

}


//@Test

public void testSearch1() {

// 2 page order by bno desc

Pageable pageable = PageRequest.of(1, 10, Sort.by("bno").descending());


boardRepository.search1(pageable);

}


}





[콘솔 내용]
Hibernate: 
    select
        b1_0.bno,
        b1_0.content,
        b1_0.moddate,
        b1_0.regdate,
        b1_0.title,
        b1_0.writer 
    from
        board b1_0 
    where
        (
            b1_0.title like ? escape '!' 
            or b1_0.content like ? escape '!' 
            or b1_0.writer like ? escape '!'
        ) 
        and b1_0.bno>? 
    order by
        b1_0.bno desc 
    limit
        ?, ?
Hibernate: 
    select
        count(b1_0.bno) 
    from
        board b1_0 
    where
        (
            b1_0.title like ? escape '!' 
            or b1_0.content like ? escape '!' 
            or b1_0.writer like ? escape '!'
        ) 
        and b1_0.bno>?

댓글목록 0

등록된 댓글이 없습니다.


Copyright © dancePKT. All rights reserved.
PC 버전으로 보기