package java.pms.dao;


import java.util.List;

import java.util.Map;


import pms.domain.Tour;


public interface TourDao {

    int delete(int no) ;

    List<Tour> selectList(Map<String,Object> params);

    //여러개의 Tour 객체(클래스)를 리스트에 담아서 내보낸다

    int insert(Tour tour);

    int update(Tour tour);

    Tour selectOne(int no);

}


// delete, selectList, insert, update, selectOne등은 마이바티스 xml 파일에 있는 sql문에 존재하는 id와 일치해야 한다.

예를 들어 아래의 xml의 mapper의 sql 예이다.   

 <select id="selectList

          resultMap="TourMap" 

          parameterType="map">

    select bno, title, createdtime 

    from tamlaDB_tourboard

    order by bno desc

    limit #{startRowNo}, #{pageSize}

  </select>

  

  <insert id="insert" parameterType="Tour"

          useGeneratedKeys="true" keyColumn="bno" keyProperty="no">

    insert into tamlaDB_tourboard(title,cont,cdt) 

    values(#{title},#{content},now())

  </insert>


resultMap - 데이터베이스에서 결과데이터를 객체에 로드하는 방법을 정의하는 엘리먼트// 쉽게 생각 하려면 값을 내보내는 것은 resultMap이라고 생각해두자(아직 이해가 잘 되지 않음..

parameterType -  파라미터를 매핑하기 위해 사용. 값을 받아오는 역할을 한다.


'프로그래밍 > MyBatis' 카테고리의 다른 글

MyBatis Configure  (0) 2019.11.12
Posted by kingroad

블로그 이미지
개발자를 꿈꾸는 코린이 입니다
kingroad

태그목록

공지사항

Yesterday
Today
Total

달력

 « |  » 2025.5
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31

최근에 올라온 글

최근에 달린 댓글

글 보관함