반응형

Mybatis 4

There is no getter for property named 'recordsPerPage' in 'class com.reviewer.portfolio.vo.paging.Criteria' 에러 해결 방법

이 에러는 mybatis 사용 시 쿼리가 작성되는 xml 파일에 #{} 부분의 변수명이 파라미터 타입의 필드명과 달라서 발생하는 에러이다. - PageVO @Component @Data @NoArgsConstructor public class PageVO { private int pageCnt; private int startPage; private int endPage; private int realEnd; private boolean prev, next; private int total; private Criteria criteria; ... } - .xml 파일 select id, category, title, url, file_id AS fileId, thumbnail_id AS thumbnail..

Mybatis 2022.03.24

Mybatis 시작하기

1. pom.xml 파일에 mybatis 라이브러리를 추가 org.mybatis mybatis xxx 2. XML에서 SqlSessionFactory를 빌드 // JDBC 연결과 관련된 설정 // SQL 코드와 매핑에 대한 정의를 가지는 Mapper 관련된 설정 SqlSessionFactory란? mybatis를 이용하여 SqlSession을 열거나 쿼리를 실행할 때 SqlSessionFactory를 사용한다. SqlSessionFactory는 Mybatis 설정파일(xml)과 SqlSessionFactoryBuilder 로 인스턴스를 생성한다. Mybatis 설정파일이란? JDBC 연결과 관련된 설정 & SQL 코드와 매핑을 정의한 Mapper 에 대한 설정을 해준다. 3. SqlSessionFacto..

Mybatis 2022.01.10

<foreach> 문에 대하여

List names = {"kim", "lee", "park"}; SELECT * FROM 테이블명 WHERE 1=1 AND ${name} IN #{n} collection - 전달받은 인자( 반드시 List 이거나 Array 형태 ) item - collection의 alias 명 open - 구문 시작할 때 삽입할 문자열 close - 구문 종료할 때 삽입할 문자열 separator - 반복 구문 사이에 출력하는 구분자 index - 반복되는 구문 번호 ( 0부터 순차 증가 ) ▶ MyBatis에서 #{}와 ${}의 차이점 ? - #{} : 작은 따옴표(')가 자동으로 붙어서 쿼리가 실행된다. - ${} : 테이블명이나 컬럼명을 동적으로 사용할 때 쓰인다.

Mybatis 2021.12.21
반응형