๐Ÿ’ป

JSP ํ”„๋กœ๊ทธ๋ž˜๋ฐ - [MyBatis] ๋งคํ•‘(Mapping)/mapper ์„ค์ • ๋ณธ๋ฌธ

KITRI/JSP

JSP ํ”„๋กœ๊ทธ๋ž˜๋ฐ - [MyBatis] ๋งคํ•‘(Mapping)/mapper ์„ค์ •

๋˜ํšจ๋‹ˆ 2020. 7. 13. 16:47

MyBatis ๊ฐ์ฒด์˜ ์Šค์ฝ”ํ”„์™€ ์ƒ๋ช… ์ฃผ๊ธฐ

 

 

 

SqlSessionFactoryBuilder -> SqlSessionFactory -> SqlSession -> Mapper

 

 

SqlSessionFactoryBuilder

 

์ด ํด๋ž˜์Šค๋Š” ์ธ์Šคํ„ด์Šคํ™” ๋˜์–ด ์‚ฌ์šฉ๋˜๊ณ  ๋˜์ ธ์งˆ ์ˆ˜ ์žˆ๋‹ค. SqlSessionFactory ๋ฅผ ์ƒ์„ฑํ•œ ํ›„ ์œ ์ง€ํ•  ํ•„์š”๋Š” ์—†๋‹ค. ๊ทธ๋Ÿฌ๋ฏ€๋กœ SqlSessionFactoryBuilder ์ธ์Šคํ„ด์Šค์˜ ๊ฐ€์žฅ ์ข‹์€ ์Šค์ฝ”ํ”„๋Š” ๋ฉ”์†Œ๋“œ ์Šค์ฝ”ํ”„(์˜ˆ๋ฅผ๋“ค๋ฉด ๋ฉ”์†Œ๋“œ ์ง€์—ญ๋ณ€์ˆ˜)์ด๋‹ค. ์—ฌ๋Ÿฌ ๊ฐœ์˜ SqlSessionFactory ์ธ์Šคํ„ด์Šค๋ฅผ ๋นŒ๋“œํ•˜๊ธฐ ์œ„ํ•ด SqlSessionFactoryBuilder๋ฅผ ์žฌ์‚ฌ์šฉํ•  ์ˆ˜๋„ ์žˆ์ง€๋งŒ ์œ ์ง€ํ•˜์ง€ ์•Š๋Š” ๊ฒƒ์ด ๊ฐ€์žฅ ์ข‹๋‹ค.

 

 

SqlSessionFactory

 

ํ•œ๋ฒˆ ๋งŒ๋“ ๋’ค SqlSessionFactory๋Š” ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ์‹คํ–‰ํ•˜๋Š” ๋™์•ˆ ์กด์žฌํ•ด์•ผ๋งŒ ํ•œ๋‹ค. ๊ทธ๋ž˜์„œ ์‚ญ์ œํ•˜๊ฑฐ๋‚˜ ์žฌ์ƒ์„ฑํ•  ํ•„์š”๊ฐ€ ์—†๋‹ค. ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์ด ์‹คํ–‰๋˜๋Š” ๋™์•ˆ ์—ฌ๋Ÿฌ ์ฐจ๋ก€ SqlSessionFactory ๋ฅผ ๋‹ค์‹œ ๋นŒ๋“œํ•˜์ง€ ์•Š๋Š” ๊ฒƒ์ด ๊ฐ€์žฅ ์ข‹์€ ํ˜•ํƒœ์ด๋‹ค. ์žฌ๋นŒ๋“œํ•˜๋Š” ํ˜•ํƒœ๋Š” ์ข‹์ง€ ์•Š๋‹ค. ๊ทธ๋Ÿฌ๋ฏ€๋กœ SqlSessionFactory ์˜ ๊ฐ€์žฅ ์ข‹์€ ์Šค์ฝ”ํ”„๋Š” ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ์Šค์ฝ”ํ”„์ด๋‹ค. ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ์Šค์ฝ”ํ”„๋กœ ์œ ์ง€ํ•˜๊ธฐ ์œ„ํ•œ ๋‹ค์–‘ํ•œ ๋ฐฉ๋ฒ•์ด ์กด์žฌํ•œ๋‹ค. ๊ฐ€์žฅ ๊ฐ„๋‹จํ•œ ๋ฐฉ๋ฒ•์€ ์‹ฑ๊ธ€ํ„ด ํŒจํ„ด์ด๋‚˜ static ์‹ฑ๊ธ€ํ„ด ํŒจํ„ด์„ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด๋‹ค. ๋˜๋Š” ๊ตฌ๊ธ€ ์ฅฌ์Šค๋‚˜ ์Šคํ”„๋ง๊ณผ ๊ฐ™์€ ์˜์กด์„ฑ ์‚ฝ์ž… ์ปจํ…Œ์ด๋„ˆ๋ฅผ ์„ ํ˜ธํ•  ์ˆ˜๋„ ์žˆ๋‹ค. ์ด๋Ÿฌํ•œ ํ”„๋ ˆ์ž„์›Œํฌ๋Š” SqlSessionFactory์˜ ์ƒ๋ช…์ฃผ๊ธฐ๋ฅผ ์‹ฑ๊ธ€ํ„ด์œผ๋กœ ๊ด€๋ฆฌํ•  ๊ฒƒ์ด๋‹ค.

 

 

SqlSession

 

๊ฐ๊ฐ์˜ ์“ฐ๋ ˆ๋“œ๋Š” ์ž์ฒด์ ์œผ๋กœ SqlSession์ธ์Šคํ„ด์Šค๋ฅผ ๊ฐ€์ ธ์•ผ ํ•œ๋‹ค. SqlSession์ธ์Šคํ„ด์Šค๋Š” ๊ณต์œ ๋˜์ง€ ์•Š๊ณ  ์“ฐ๋ ˆ๋“œ์— ์•ˆ์ „ํ•˜์ง€๋„ ์•Š๋‹ค. ๊ทธ๋Ÿฌ๋ฏ€๋กœ ๊ฐ€์žฅ ์ข‹์€ ์Šค์ฝ”ํ”„๋Š” ์š”์ฒญ ๋˜๋Š” ๋ฉ”์†Œ๋“œ ์Šค์ฝ”ํ”„์ด๋‹ค. SqlSession ์„ static ํ•„๋“œ๋‚˜ ํด๋ž˜์Šค์˜ ์ธ์Šคํ„ด์Šค ํ•„๋“œ๋กœ ์ง€์ •ํ•ด์„œ๋Š” ์•ˆ๋œ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ์„œ๋ธ”๋ฆฟ ํ”„๋ ˆ์ž„์›Œํฌ์˜ HttpSession ๊ณผ ๊ฐ™์€ ๊ด€๋ฆฌ ์Šค์ฝ”ํ”„์— ๋‘ฌ์„œ๋„ ์•ˆ๋œ๋‹ค. ์–ด๋– ํ•œ ์ข…๋ฅ˜์˜ ์›น ํ”„๋ ˆ์ž„์›Œํฌ๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค๋ฉด HTTP ์š”์ฒญ๊ณผ ์œ ์‚ฌํ•œ ์Šค์ฝ”ํ”„์— ๋‘๋Š” ๊ฒƒ์œผ๋กœ ๊ณ ๋ คํ•ด์•ผ ํ•œ๋‹ค. ๋‹ฌ๋ฆฌ ๋งํ•ด์„œ HTTP ์š”์ฒญ์„ ๋ฐ›์„๋•Œ๋งˆ๋‹ค ๋งŒ๋“ค๊ณ  ์‘๋‹ต์„ ๋ฆฌํ„ดํ• ๋•Œ๋งˆ๋‹ค SqlSession ์„ ๋‹ซ์„ ์ˆ˜ ์žˆ๋‹ค. SqlSession ์„ ๋‹ซ๋Š” ๊ฒƒ์€ ์ค‘์š”ํ•˜๋‹ค. ์–ธ์ œ๋‚˜ finally ๋ธ”๋ก์—์„œ ๋‹ซ์•„์•ผ๋งŒ ํ•œ๋‹ค. ๋‹ค์Œ์€ SqlSession์„ ๋‹ซ๋Š” ๊ฒƒ์„ ํ™•์ธํ•˜๋Š” ํ‘œ์ค€์ ์ธ ํ˜•ํƒœ๋‹ค.

 

try (SqlSession session = sqlSessionFactory.openSession()) {
	// do work 
}

์ฝ”๋“œ์ „๋ฐ˜์— ์ด๋Ÿฐ ํ˜•ํƒœ๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์€ ๋ชจ๋“  ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์ž์›์„ ์ž˜ ๋‹ซ๋Š” ๊ฒƒ์œผ๋กœ ๋ณด์žฅํ•˜๊ฒŒ ํ•  ๊ฒƒ์ด๋‹ค.

 

 

Mapper ์ธ์Šคํ„ด์Šค

 

Mapper๋Š” ๋งคํ•‘๋œ ๊ตฌ๋ฌธ์„ ๋ฐ”์ธ๋”ฉ ํ•˜๊ธฐ ์œ„ํ•ด ๋งŒ๋“ค์–ด์•ผ ํ•  ์ธํ„ฐํŽ˜์ด์Šค์ด๋‹ค. mapper ์ธํ„ฐํŽ˜์ด์Šค์˜ ์ธ์Šคํ„ด์Šค๋Š” SqlSession ์—์„œ ์ƒ์„ฑํ•œ๋‹ค. ๊ทธ๋ž˜์„œ mapper ์ธ์Šคํ„ด์Šค์˜ ๊ฐ€์žฅ ์ข‹์€ ์Šค์ฝ”ํ”„๋Š” SqlSession ๊ณผ ๋™์ผํ•˜๋‹ค. ์–ด์จŒ๋“  mapper ์ธ์Šคํ„ด์Šค์˜ ๊ฐ€์žฅ ์ข‹์€ ์Šค์ฝ”ํ”„๋Š” ๋ฉ”์†Œ๋“œ ์Šค์ฝ”ํ”„์ด๋‹ค. ์‚ฌ์šฉํ•  ๋ฉ”์†Œ๋“œ๊ฐ€ ํ˜ธ์ถœ๋˜๋ฉด ์ƒ์„ฑ๋˜๊ณ  ๋๋‚œ๋‹ค. ๋ช…์‹œ์ ์œผ๋กœ ๋‹ซ์„ ํ•„์š”๋Š” ์—†๋‹ค.

try (SqlSession session = sqlSessionFactory.openSession()) { 
	BlogMapper mapper = session.getMapper(BlogMapper.class); 
    // do work 
}

 

 

์ด์ „์— jsp๋กœ ์ž‘์„ฑํ•œ ํšŒ์›๊ฐ€์ž…/๋กœ๊ทธ์ธ, ๊ฒŒ์‹œํŒ, ํŒŒ์ผ๊ฒŒ์‹œํŒ (member, board, file 

 

com.java.myBatis ํŒจํ‚ค์ง€๋ฅผ ์ถ”๊ฐ€ํ•ด์„œ SqlCofig.xml, SqlManager.java ํŒŒ์ผ์„ ์ž‘์„ฑํ•œ๋‹ค.

 

SqlConfig.xml

<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE configuration
  PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
  "http://mybatis.org/dtd/mybatis-3-config.dtd">

<configuration>
  <environments default="development">
    <environment id="development">
      <transactionManager type="JDBC"/>
      <dataSource type="UNPOOLED">
        <property name="driver" value="oracle.jdbc.driver.OracleDriver"/>
        <property name="url" value="jdbc:oracle:thin:@localhost:1521:xe"/>
        <property name="username" value="mvc"/>
        <property name="password" value="1234"/>
      </dataSource>
    </environment>
  </environments>
  <mappers>
    <mapper resource="/com/java/member/model/mapper/MemberMapper.xml"/>
    <mapper resource="/com/java/board/model/mapper/BoardMapper.xml"/>
  </mappers>
</configuration>

 

SqlManager.java

package com.java.myBatis;

import java.io.IOException;
import java.io.InputStream;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

public class SqlManager {
    private static SqlSessionFactory sqlSessionFactory;
    
    public static SqlSessionFactory getInstance() {
	
	try {
	    String resource = "com/java/myBatis/SqlConfig.xml";
	    InputStream inputStream = Resources.getResourceAsStream(resource);
	    sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
	} catch (IOException e) {
	    e.printStackTrace();
	}
	return sqlSessionFactory;
    }
}

 

com.java.member.model.mapping ํŒจํ‚ค์ง€๋ฅผ ์ถ”๊ฐ€ํ•ด์„œ MemberMapping.xml ํŒŒ์ผ์„ ์ž‘์„ฑํ•œ๋‹ค.

 

MemberMapping.xml 

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE mapper
    PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
    "http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="com.java.member.model.mapper.MemberMapper">
	<resultMap type="com.java.member.model.MemberDto" id="member_dto">
		<result column="num" property="num"/>
		<result column="id" property="id"/>
		<result column="password" property="password"/>
		<result column="name" property="name"/>
		<result column="jumin1" property="jumin1"/>
		<result column="jumin2" property="jumin2"/>
		<result column="email" property="email"/>
		
		<result column="zipcode" property="zipcode"/>
		<result column="address" property="address"/>
		<result column="job" property="job"/>
		<result column="mailing" property="mailing"/>
		<result column="interest" property="interest"/>
		<result column="member_level" property="memberLevel"/>
		<result column="register_date" property="registerDate"/>
	</resultMap>

<!-- ๋“ค์–ด์˜ค๋Š” ๊ฒƒ์€ parameterType ๋‚˜๊ฐ€๋Š” ๊ฒƒ์€ resultType id๋Š” ์‹๋ณ„์ž, insert๋Š” resultType ์ƒ๋žต -->
	<insert id="member_insert" parameterType="com.java.member.model.MemberDto">
		insert into member values(
				member_num_seq.nextval,
				#{id},
				#{password},
				#{name},
				#{jumin1},
				#{jumin2},
				#{email},
				#{zipcode},
				#{address},
				#{job},
				#{mailing},
				#{interest},
				#{memberLevel},
				sysdate
		)
	</insert>
	
	<select id="id_check" parameterType="java.lang.String" resultType="java.lang.String">
		select id from member 
				  where id = #{id}
	</select>
	
	<select id="member_zipcode" parameterType="String" resultType="com.java.member.model.MemberDto">
		select * from zipcode 
				 where dong = ${checkDong}		
	</select>
	
	<select id="member_login" parameterType="java.util.Map" resultType="String">
		select member_level from member 
							where id = #{id}
							and password = #{password}
	</select>
	
	<select id="member_select" parameterType="String" resultMap="member_dto">
		select * from member 
				 where id = #{id}
	</select>
	
	<update id="member_update" parameterType="com.java.member.model.MemberDto">
		update member set password = #{password}, 
						  email = #{email}, 
						  zipcode = #{zipcode}, 
						  address = #{address}, 
						  job = #{job}, 
						  mailing = #{mailing}, 
						  interest = #{interest} 
					  where num = #{num}
	</update>
	<delete id="member_delete" parameterType="java.util.Map">
		delete from member where id = #{id} and password = #{password}
	</delete>
</mapper>

 

 

BoardDao.java

package com.java.board.model;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;

import com.java.database.ConnectionProvider;
import com.java.database.jdbcUtil;
import com.java.myBatis.SqlManager;

public class BoardDao {
    private static SqlSessionFactory sqlSessionFactory = SqlManager.getInstance();
    private SqlSession session;
    
    private static BoardDao instance = new BoardDao();

    public static BoardDao getInstance() {
	return instance;
    }

    public int insert(BoardDto boardDto) {
	Connection conn = null;
	PreparedStatement pstmt = null;
	int value = 0;

	writeNumber(boardDto);
	
	try {	    
	    session = sqlSessionFactory.openSession();
	    value = session.insert("board_insert", boardDto);
	    session.commit();
	} catch (Exception e) {
	    e.printStackTrace();
	} finally {
	    session.close();
	}
	return value;
    }

    public void writeNumber(BoardDto boardDto) {
	// ๊ทธ๋ฃน๋ฒˆํ˜ธ(ROOT), ๊ธ€์ˆœ์„œ(์ž์‹), ๊ธ€๋ ˆ๋ฒจ(์ž์‹)
	int boardNumber = boardDto.getBoardNumber(); // 0
	int groupNumber = boardDto.getGroupNumber(); // 1
	int sequenceNumber = boardDto.getSequenceNumber(); // 0
	int sequenceLevel = boardDto.getSequenceLevel(); // 0

	try {
	    if (boardNumber == 0) { // ROOT : ๊ทธ๋ฃน๋ฒˆํ˜ธ
		session = sqlSessionFactory.openSession();
		int max = session.selectOne("board_group_number_max");
		
		if(max!=0) boardDto.setGroupNumber(max+1);

	    } else { // ๋‹ต๊ธ€ : ๊ธ€ ์ˆœ์„œ, ๊ธ€ ๋ ˆ๋ฒจ
		  HashMap<String, Integer> hMap = new HashMap<String, Integer>();
		  
		  session = sqlSessionFactory.openSession();
		  hMap.put("sequenceNumber", sequenceNumber);
		  hMap.put("sequenceLevel", sequenceLevel);
		  session.update("board_sequence_number", hMap);
		  
		  sequenceNumber = sequenceNumber + 1; 
		  sequenceLevel = sequenceLevel + 1;
		  
		  boardDto.setSequenceNumber(sequenceNumber);
		  boardDto.setSequenceLevel(sequenceLevel);
		 
	    }
	} catch (Exception e) {
	    e.printStackTrace();
	} finally {
	    session.close();
	}
    }

    public int getCount() {
	int value = 0;

	try {
	    session = sqlSessionFactory.openSession();
	    value = session.selectOne("board_count");
	    
	} catch (Exception e) {
	    e.printStackTrace();
	} finally {
	    session.close();
	}
	return value;
    }

    public List<BoardDto> getBoardList(int startRow, int endRow) {
	HashMap<String, Integer> hMap = new HashMap<String, Integer>();
	hMap.put("startRow", startRow);
	hMap.put("endRow", endRow);
	List<BoardDto> boardList = null;

	try {
	    session = sqlSessionFactory.openSession();
	    boardList = session.selectList("board_list", hMap);
	    
	} catch (Exception e) {
	    e.printStackTrace();
	} finally {
	    session.close();
	}
	return boardList;
    }

    public BoardDto read(int boardNumber) {
	BoardDto boardDto = null;
	
	try {
	    session = sqlSessionFactory.openSession();
	    session.update("board_update_count", boardNumber);
	    boardDto = session.selectOne("board_read", boardNumber);
	    session.commit();
	}catch (Exception e) {
	    e.printStackTrace();
	    session.rollback();
	}finally {
	    session.close();
	}
	return boardDto;
    }

    public int delete(int boardNumber, String password) {
	HashMap<String, Object> hMap = new HashMap<String, Object>();
	int value = 0;
	
	try {
	    session = sqlSessionFactory.openSession();
	    hMap.put("boardNumber", boardNumber);
	    hMap.put("password", password);
	    
	    value = session.delete("board_delete", hMap);
	    session.commit();
	} catch (Exception e) {
	    e.printStackTrace();
	    session.rollback();
	} finally {
	    session.close();
	}
	return value;
    }

    public BoardDto getContentList(int boardNumber) {
	BoardDto boardDto = null;
	
	try {
	    session = sqlSessionFactory.openSession();
	    boardDto = session.selectOne("board_select", boardNumber);
	} catch (Exception e) {
	    e.printStackTrace();
	} finally {
	    session.close();
	}
	return boardDto;
    }
    
    public int update(int boardNumber, BoardDto boardDto) {
	HashMap<String, Object> hMap = new HashMap<String, Object>();
	int value = 0;
	
	try {
	   session = sqlSessionFactory.openSession();
	   hMap.put("boardNumber", boardNumber);
	   hMap.put("boardDto", boardDto);
	   value = session.update("board_update", hMap);
	   session.commit();
	    
	} catch (Exception e) {
	    e.printStackTrace();
	    session.rollback();
	} finally {
	    session.close();
	}
	return value;
    }
}

ArrayList๋กœ ์ž‘์„ฑํ–ˆ๋˜ ๊ฒƒ์„ List๋กœ ์—…์บ์ŠคํŒ… ํ•ด์ฃผ๊ณ  ListCommand.java ํŒŒ์ผ์—์„œ๋„ List๋กœ ๋ฐ”๊ฟ”์ค€๋‹ค.

 

BoardMapping.xml

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE mapper
    PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
    "http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="com.java.board.model.mapper.BoardMapper">
	<resultMap type="com.java.board.model.BoardDto" id="board_dto">
		<result column="board_number" property="boardNumber"/>
			<result column="num" property="num"/>
			<result column="id" property="id"/>
			<result column="password" property="password"/>
			<result column="name" property="name"/>
			<result column="jumin1" property="jumin1"/>
			<result column="jumin2" property="jumin2"/>
			<result column="email" property="email"/>
			
			<result column="zipcode" property="zipcode"/>
			<result column="address" property="address"/>
			<result column="job" property="job"/>
			<result column="mailing" property="mailing"/>
			<result column="interest" property="interest"/>
			<result column="member_level" property="memberLevel"/>
			<result column="register_date" property="registerDate"/>
	</resultMap>
	
	<select id="board_group_number_max" resultType="int">
		select nvl(max(group_number), 0) from board
	</select>
	<update id="board_sequence_number" parameterType="java.util.HashMap">
		update board set sequence_number = sequence_number+1
		  			 where group_number = #{sequenceLevel} 
		  			 and sequence_number > #{sequenceNumber}
	</update>
	<select id="board_insert" parameterType="com.java.board.model.BoardDto">
		insert into board(
						board_number, 
						writer, 
						subject, 
						email, 
						content, 
						password,
						write_date, 
						read_count, 
						group_number, 
						sequence_number, 
						sequence_level)
		       values (board_number_seq.nextval,
		       			#{writer},
		       			#{subject},
		       			#{email},
		       			#{content},
		       			#{password},
		       			#{writeDate},
		       			#{readCount},
		       			#{groupNumber},
		       			#{sequenceNumber},
		       			#{sequenceLevel})
	</select>
	<select id="board_count" resultType="int">
		select count(*) from board
	</select>
	<select id="board_list" parameterType="java.util.HashMap" resultMap="board_dto">
		<!-- ์ฟผ๋ฆฌ๋ฌธ ์•ˆ์— ํŠน์ˆ˜๋ฌธ์ž๊ฐ€ ๋งŽ์€ ๊ฒฝ์šฐ์— ๋ช…๋ น์–ด๋กœ ์ธ์‹ํ•ด์„œ ์—๋Ÿฌ๊ฐ€ ๋‚˜๊ธฐ๋•Œ๋ฌธ์— ํ•„์š” -->
		<![CDATA[
		select * from
		         (select rownum as rnum, a.* from 
		         							(select * FROM board 
		         							          order by group_number desc, 
		         							                    sequence_number asc) a) b 
		    	 where b.rnum >= #{startRow} and b.rnum <= #{endRow}
		]]>
	</select>
	<update id="board_update_count" parameterType="int">
		<![CDATA[
		update board set read_count = read_count+1
	    			 where board_number = #{boardNumber}
	    ]]>
	</update>
	<select id="board_read" parameterType="int" resultMap="board_dto">
		select * from board
				 where board_number = #{boardNumber}
	</select>
	<delete id="board_delete" parameterType="java.util.HashMap">
		delete from board 
			   where board_number = #{boardNumber} 
			   and password = #{password}
	</delete>
	<select id="board_select" parameterType="int" resultMap="board_dto">
		select * from board 
			     where board_number = #{boardNumber} 
	</select>
	<update id="board_update" parameterType="java.util.HashMap">
		update board set subject = #{boardDto.subject},
		    		 	 email = #{boardDto.email},
		    		 	 content = #{boardDto.content},
		    		 	 password = #{boardDto.password},
		    		 	 write_date = #{boardDto.writeDate}
	    			 where board_number = #{boardDto.boardNumber}
	</update>
</mapper>

int,String,float์€ java.lang ํŒจํ‚ค์ง€๋ช… ์•ˆ์จ๋‘ ๋จ.

๋ฐ˜์‘ํ˜•
Comments