카테고리 없음

MyBatis

나주나주 2024. 3. 7. 17:40
Mapper XML Elements 설명
cache 해당 namespace를 위한 캐시 설정
cache-ref 다른 namespace의 캐시 설정에 대한 참조
resultMap DB 결과 데이터를 표로 출력
parameterMap 비권장!
<sql > 다른 구문에서 재사용하기 위한 sql 
< insert > 매핑된 insert문
< update >  
< delete >  
< select >  

 

select

: select keyword는 MyBatis에게 PreparedStatement 파라미터를 만들도록 지시한다

//Mapper에 동일한 이름을 가진 메서드와 id로 연결, int타입의 파라미터, 결과는 HashMap에 저장

<select id="selectPerson" parameterTYpe="int" resultType="hashmap">
	SELECT * FROM PERSON WHERE ID = #{id}
</select>
select Attributes 설명
id 구문을 찾기 위해 사용될 수 있는 namespace 내 유일한 구분자
parameterType 구문에 전달될 파라미터의 패키지 경로를 포함한 전체 클래스명이나 별칭
resultType resultMap, resultType 함께 사용 불가

The fully qualified class name or alias for the expected type that will be returned from this statement. Note that in the case of collections, this should be the type that the collection contains, not the type of the collection itself. 
resultMap 결과를 표로 매핑
flushCache