마지막으로 자바파일입니다.
iBatis에서 사용하는 쿼리용 xml파일은 classes에 있어야 하니까 주의하세요.
저같은 경우는 자바파일이 있는 폴더에 두었다가 ant로 파일을 복사했습니다.
/////////////////////////////////////////////////////
// BoardAction.java
/////////////////////////////////////////////////////
package web.board;
import java.util.*;
import javax.servlet.ServletContext;
import javax.servlet.http.*;
import org.apache.log4j.Logger;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.interceptor.*;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
import com.opensymphony.xwork2.*;
import core.board.*;
import core.common.Common;
/**
* Base Action class for the Tutorial package.
*/
public class BoardAction extends ActionSupport implements ServletRequestAware {
private HttpServletRequest request;
private Logger logger = Logger.getLogger(this.getClass());
private IBoard board;
private Collection boardCol;
private BoardVO boardVO;
/**
* 화면이동
* @throws Exception
*/
public String forward() throws Exception {
try{
logger.info("forward start");
logger.info("forward :" + request.getParameter("forward"));
logger.info("forward end");
return request.getParameter("forward");
}catch(Exception e){
logger.info("Error : " + e.toString());
e.printStackTrace();
throw e;
}
}
/**
* 게시물 목록조회
* @throws Exception
*/
public String searchBoard() throws Exception {
try{
logger.info("searchBoard start");
// request를 가져온다.
BoardVO boardVO = new BoardVO();
Common.fromRequestToVO(request, boardVO);
ServletContext servletContext = ServletActionContext.getServletContext();
WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(servletContext);
this.board = (IBoard)wac.getBean("board");
setBoardVO(board.getBoardList(boardVO));
logger.info("forward :" + request.getParameter("forward"));
logger.info("searchBoard end");
return request.getParameter("forward");
}catch(Exception e){
logger.info("Error : " + e.toString());
e.printStackTrace();
throw e;
}
}
/**
* 게시물 조회
* @throws Exception
*/
public String viewBoard() throws Exception {
try{
logger.info("viewBoard start");
// request를 가져온다.
BoardVO boardVO = new BoardVO();
Common.fromRequestToVO(request, boardVO);
ServletContext servletContext = ServletActionContext.getServletContext();
WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
this.board = (IBoard)wac.getBean("board");
setBoardVO(board.getBoard(boardVO));
logger.info("forward :" + request.getParameter("forward"));
logger.info("viewBoard end");
return request.getParameter("forward");
}catch(Exception e){
logger.info("Error : " + e.toString());
e.printStackTrace();
throw e;
}
}
/**
* 게시물 입력
* @throws Exception
*/
public String insertBoard() throws Exception {
try{
logger.info("insertBoard start");
// request를 가져온다.
BoardVO boardVO = new BoardVO();
Common.fromRequestToVO(request, boardVO);
ServletContext servletContext = ServletActionContext.getServletContext();
WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
this.board = (IBoard)wac.getBean("board");
board.insertBoard(boardVO);
logger.info("forward :" + request.getParameter("forward"));
logger.info("insertBoard end");
return request.getParameter("forward");
}catch(Exception e){
logger.info("Error : " + e.toString());
e.printStackTrace();
throw e;
}
}
/**
* 게시물 수정
* @throws Exception
*/
public String updateBoard() throws Exception {
try{
logger.info("updateBoard start");
// request를 가져온다.
BoardVO boardVO = new BoardVO();
Common.fromRequestToVO(request, boardVO);
ServletContext servletContext = ServletActionContext.getServletContext();
WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
this.board = (IBoard)wac.getBean("board");
board.updateBoard(boardVO);
logger.info("forward :" + request.getParameter("forward"));
logger.info("updateBoard end");
return request.getParameter("forward");
}catch(Exception e){
logger.info("Error : " + e.toString());
e.printStackTrace();
throw e;
}
}
/**
* 게시물 삭제
* @throws Exception
*/
public String deleteBoard() throws Exception {
try{
logger.info("deleteBoard start");
// request를 가져온다.
BoardVO boardVO = new BoardVO();
Common.fromRequestToVO(request, boardVO);
ServletContext servletContext = ServletActionContext.getServletContext();
WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
this.board = (IBoard)wac.getBean("board");
board.deleteBoard(boardVO);
logger.info("forward :" + request.getParameter("forward"));
logger.info("deleteBoard end");
return request.getParameter("forward");
}catch(Exception e){
logger.info("Error : " + e.toString());
e.printStackTrace();
throw e;
}
}
public void setServletRequest(HttpServletRequest request) {
this.request = request;
}
public void setBoardCol(Collection boardCol) {
this.boardCol = boardCol;
}
public Collection getBoardCol() {
return boardCol;
}
public BoardVO getBoardVO() {
return boardVO;
}
public void setBoardVO(BoardVO boardVO) {
this.boardVO = boardVO;
}
}
/////////////////////////////////////////////////////
// Common.java
/////////////////////////////////////////////////////
package core.common;
import java.lang.reflect.*;
import java.util.*;
import javax.servlet.http.HttpServletRequest;
public class Common {
/**
* request에 있는 변수의 값을 targetVO로 copy
* @param HttpServletRequest request, Object targetVO
* @return void
* @throws Exception
*/
public static void fromRequestToVO(HttpServletRequest request, Object targetVO){
try{
Enumeration parameteraNameEnu = request.getParameterNames();
Field[] fields = targetVO.getClass().getDeclaredFields();
boolean isFieldExist;
while(parameteraNameEnu.hasMoreElements()){
String parameterName = (String)parameteraNameEnu.nextElement();
isFieldExist = isFieldExist(parameterName, fields);
if(isFieldExist){
Class variableType = targetVO.getClass().getDeclaredField(parameterName).getType();
String variableTypeStr = variableType.getName();
String setMethodName = "set"+ parameterName.substring(0,1).toUpperCase() + parameterName.substring(1);
Method setMethod = null;
// 변수가 String인 경우
if(variableTypeStr.equals("java.lang.String")){
setMethod = targetVO.getClass().getMethod(setMethodName, new Class[] {variableType});
setMethod.invoke(targetVO, new Object[] {request.getParameter(parameterName)});
}
// 변수가 String[]인 경우
else if(variableTypeStr.equals("[Ljava.lang.String;")){
setMethod = targetVO.getClass().getMethod(setMethodName, new Class[] {variableType});
setMethod.invoke(targetVO, new Object[] {request.getParameterValues(parameterName)});
}
}
}
}catch(Exception e){
System.out.println("Error : " + e.toString());
}
}
/**
* VO에 있는 변수가 request에 있는지 여부 조회
* @param String parameterName, Field[] fields
* @return void
* @throws Exception
*/
public static boolean isFieldExist(String parameterName, Field[] fields){
boolean result = false;
try{
int i = 0;
while(i < fields.length){
Field field = fields[i];
if(field.getName().equals(parameterName)){
return true;
}
i++;
}
}catch(Exception e){
System.out.println("Error : " + e.toString());
}
return result;
}
/**
* 페이징 결과 작성
* @param String count, String page, int listCount
* @return String
* @throws Exception
*/
public static String getResultPageStr(String count, String page, int listCount){
StringBuffer returnSb = new StringBuffer();
try{
int countInt = Integer.parseInt(count);
int pageInt = Integer.parseInt(page);
int startPage = (((pageInt - 1) / listCount ) * listCount ) + 1;
int endPage = startPage + 9;
int lastPage;
if(countInt % listCount == 0){
lastPage = ((countInt - 1) / listCount) + 1;
}else{
lastPage = (countInt / listCount) + 1;
}
returnSb.append("<table>\n");
returnSb.append(" <tr>\n");
returnSb.append(" <td>\n");
returnSb.append(" Result page :\n");
returnSb.append(" </td>\n");
// previous
if(startPage > 1){
returnSb.append(" <td>\n");
returnSb.append(" <a href="javascript:parent.searchBoard('" + (startPage - 1) + "')">\n");
returnSb.append(" 이전 페이지");
returnSb.append(" </a>\n");
returnSb.append(" </td>\n");
}
for(int i = startPage ; i <= endPage ; i++){
if(pageInt == i){
returnSb.append(" <td class='td_selecdIndex'>\n");
}else{
returnSb.append(" <td>\n");
}
returnSb.append(" <a href="javascript:parent.searchBoard('" + i + "')">\n");
returnSb.append(" " + i + "\n");
returnSb.append(" </a>\n");
returnSb.append(" </td>\n");
if(lastPage == i){
i = endPage;
}
}
System.out.println("endPage : " + endPage);
System.out.println("lastPage : " + lastPage);
// next
if(endPage < lastPage){
returnSb.append(" <td>\n");
returnSb.append(" <a href="javascript:parent.searchBoard('" + (endPage + 1) + "')">\n");
returnSb.append(" 다음 페이지");
returnSb.append(" </a>\n");
returnSb.append(" </td>\n");
}
returnSb.append(" </tr>\n");
returnSb.append("<table>\n");
}catch(Exception e){
System.out.println("Error : " + e.toString());
e.printStackTrace();
}
return returnSb.toString();
}
}
/////////////////////////////////////////////////////
// BoardDAO.java
/////////////////////////////////////////////////////
package core.board;
import java.util.*;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
public class BoardDAO extends SqlMapClientDaoSupport{
/**
* 게시물 목록조회(주제검색)
* @param BoardVO
* @return Collection<boardVO>)
* @throws Exception
*/
public Collection getBoardListByTitle(BoardVO boardVO) throws Exception{
logger.info("getBoardListByTitle() start");
Collection boardCol = (Collection)getSqlMapClientTemplate().queryForList("getBoardListByTitle" , boardVO);
logger.info("getBoardListByTitle() end");
return boardCol;
}
/**
* 게시물 목록조회(내용검색)
* @param BoardVO
* @return Collection<boardVO>)
* @throws Exception
*/
public Collection getBoardListByContents(BoardVO boardVO) throws Exception{
logger.info("getBoardListByContents() start");
Collection boardCol = (Collection)getSqlMapClientTemplate().queryForList("getBoardListByContents" , boardVO);
logger.info("getBoardListByContents() end");
return boardCol;
}
/**
* 게시물 조회
* @param BoardVO
* @return BoardVO
* @throws Exception
*/
public BoardVO getBoard(BoardVO boardVO) throws Exception{
logger.info("getBoard() start");
BoardVO returnBoardVO = (BoardVO)getSqlMapClientTemplate().queryForObject("getBoard" , boardVO);
logger.info("getBoard() end");
return returnBoardVO;
}
/**
* 제목 조회
* @param BoardVO
* @return Collection<boardVO>)
* @throws Exception
*/
public Collection getTitle(BoardVO boardVO) throws Exception{
logger.info("getTitle() start");
Collection boardCol = (Collection)getSqlMapClientTemplate().queryForList("getTitle" , boardVO);
logger.info("getTitle() end");
return boardCol;
}
/**
* 게시물 건수 조회(주제검색)
* @param BoardVO
* @return BoardVO
* @throws Exception
*/
public BoardVO getBoardCountByTitle(BoardVO boardVO) throws Exception{
logger.info("getBoardCountByTitle() start");
BoardVO returnBoardVO = (BoardVO)getSqlMapClientTemplate().queryForObject("getBoardCountByTitle" , boardVO);
logger.info("getBoardCountByTitle() end");
return returnBoardVO;
}
/**
* 게시물 건수 조회(내용검색)
* @param BoardVO
* @return BoardVO
* @throws Exception
*/
public BoardVO getBoardCountByContents(BoardVO boardVO) throws Exception{
logger.info("getBoardCountByContents() start");
BoardVO returnBoardVO = (BoardVO)getSqlMapClientTemplate().queryForObject("getBoardCountByContents" , boardVO);
logger.info("getBoardCountByContents() end");
return returnBoardVO;
}
/**
* 게시물 건수 최대값 채번
* @param BoardVO
* @return BoardVO
* @throws Exception
*/
public BoardVO getMaxBoardSn() throws Exception{
logger.info("getMaxBoardSn() start");
BoardVO returnBoardVO = (BoardVO)getSqlMapClientTemplate().queryForObject("getMaxBoardSn");
logger.info("getMaxBoardSn() end");
return returnBoardVO;
}
/**
* 게시물 입력
* @param BoardVO
* @return void
* @throws Exception
*/
public void insertBoard(BoardVO boardVO) throws Exception{
logger.info("insertBoard() start");
getSqlMapClientTemplate().insert("insertBoard", boardVO);
logger.info("insertBoard() end");
}
/**
* 게시물 수정
* @param BoardVO
* @return void
* @throws Exception
*/
public void updateBoard(BoardVO boardVO) throws Exception{
logger.info("updateBoard() start");
getSqlMapClientTemplate().update("updateBoard", boardVO);
logger.info("updateBoard() end");
}
/**
* 게시물 삭제
* @param BoardVO
* @return void
* @throws Exception
*/
public void deleteBoard(BoardVO boardVO) throws Exception{
logger.info("deleteBoard() start");
getSqlMapClientTemplate().delete("deleteBoard", boardVO);
logger.info("deleteBoard() end");
}
}
/////////////////////////////////////////////////////
// BoardImpl.java
/////////////////////////////////////////////////////
package core.board;
import org.apache.log4j.Logger;
import core.common.Common;
public class BoardImpl implements IBoard {
private Logger logger = Logger.getLogger(this.getClass());
private BoardDAO boardDAO;
public void setBoardDAO(BoardDAO boardDAO) {
this.boardDAO = boardDAO;
}
public BoardDAO getBoardDAO() {
return boardDAO;
}
/**
* 게시물 목록조회
* @param BoardVO
* @return Collection<boardVO>)
* @throws Exception
* @throws Exception
*/
public BoardVO getBoardList(BoardVO boardVO) throws Exception{
logger.info("getBoardList() start");
try{
String searchType = boardVO.getSearchType();
// 게시물 조회
if(searchType.equals("title")){
boardVO.setCount((boardDAO.getBoardCountByTitle(boardVO)).getCount());
boardVO.setBoardCol(boardDAO.getBoardListByTitle(boardVO));
}else if(searchType.equals("contents")){
boardVO.setCount((boardDAO.getBoardCountByContents(boardVO)).getCount());
boardVO.setBoardCol(boardDAO.getBoardListByContents(boardVO));
}
// 페이징 결과 작성(한 페이지에 10개씩)
boardVO.setResultPageStr(Common.getResultPageStr(boardVO.getCount(), boardVO.getPage(), 10));
logger.info("getBoardList() end");
return boardVO;
}catch(Exception e){
logger.info("Error : " + e.toString());
e.printStackTrace();
throw e;
}
}
/**
* 게시물 조회
* @param BoardVO
* @return BoardVO
* @throws Exception
*/
public BoardVO getBoard(BoardVO boardVO) throws Exception{
BoardVO returnBoardVO = new BoardVO();
try{
logger.info("getBoard() start");
returnBoardVO = boardDAO.getBoard(boardVO);
logger.info("getBoard() end");
return returnBoardVO;
}catch(Exception e){
logger.info("Error : " + e.toString());
e.printStackTrace();
throw e;
}
}
/**
* 게시물 입력
* @param BoardVO
* @return void
* @throws SQLException
*/
public void insertBoard(BoardVO boardVO) throws Exception{
try{
logger.info("insertBoard() start");
boardVO.setSn(boardDAO.getMaxBoardSn().getSn());
boardDAO.insertBoard(boardVO);
logger.info("insertBoard() end");
}catch(Exception e){
logger.info("Error : " + e.toString());
e.printStackTrace();
throw e;
}
}
/**
* 게시물 수정
* @param BoardVO
* @return void
* @throws SQLException
*/
public void updateBoard(BoardVO boardVO) throws Exception {
try{
logger.info("updateBoard() start");
boardDAO.updateBoard(boardVO);
logger.info("updateBoard() end");
}catch(Exception e){
logger.info("Error : " + e.toString());
e.printStackTrace();
throw e;
}
}
/**
* 게시물 삭제
* @param BoardVO
* @return void
* @throws SQLException
*/
public void deleteBoard(BoardVO boardVO) throws Exception {
try{
logger.info("deleteBoard() start");
boardDAO.deleteBoard(boardVO);
logger.info("deleteBoard() end");
}catch(Exception e){
logger.info("Error : " + e.toString());
e.printStackTrace();
throw e;
}
}
}
/////////////////////////////////////////////////////
// BoardVO.java
/////////////////////////////////////////////////////
package core.board;
import java.io.Serializable;
import java.util.*;
public class BoardVO implements Serializable{
// 일련번호
private String sn;
// 타이틀
private String title;
// 내용
private String contents;
// 작성자
private String writer;
// 검색어
private String keyword;
// 검색타입
private String searchType;
// 배열 파라미터
private String[] paramArr;
// 게시물 페이지
private String page;
// 게시물 건수
private String count;
// 게시물 목록
private Collection boardCol;
// 게시물 페이지 결과 스트링
private String resultPageStr;
public String getResultPageStr() {
return resultPageStr;
}
public void setResultPageStr(String resultPageStr) {
this.resultPageStr = resultPageStr;
}
public Collection getBoardCol() {
return boardCol;
}
public void setBoardCol(Collection boardCol) {
this.boardCol = boardCol;
}
public String getCount() {
return count;
}
public void setCount(String count) {
this.count = count;
}
public String getPage() {
return page;
}
public void setPage(String page) {
this.page = page;
}
public String getContents() {
return contents;
}
public void setContents(String contents) {
this.contents = contents;
}
public String getSn() {
return sn;
}
public void setSn(String sn) {
this.sn = sn;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getWriter() {
return writer;
}
public void setWriter(String writer) {
this.writer = writer;
}
public String getKeyword() {
return keyword;
}
public void setKeyword(String keyword) {
this.keyword = keyword;
}
public String getSearchType() {
return searchType;
}
public void setSearchType(String searchType) {
this.searchType = searchType;
}
public String[] getParamArr() {
return paramArr;
}
public void setParamArr(String[] paramArr) {
this.paramArr = paramArr;
}
}
/////////////////////////////////////////////////////
// IBoard.java
/////////////////////////////////////////////////////
package core.board;
public interface IBoard {
/**
* 게시물 목록조회
* @param BoardVO
* @return Collection<boardVO>)
* @throws Exception
*/
BoardVO getBoardList(BoardVO boardVO) throws Exception;
/**
* 게시물 조회
* @param BoardVO
* @return BoardVO
* @throws Exception
*/
BoardVO getBoard(BoardVO boardVO) throws Exception;
/**
* 게시물 입력
* @param BoardVO
* @return void
* @throws Exception
*/
void insertBoard(BoardVO boardVO) throws Exception;
/**
* 게시물 수정
* @param BoardVO
* @return void
* @throws Exception
*/
void updateBoard(BoardVO boardVO) throws Exception;
/**
* 게시물 삭제
* @param BoardVO
* @return void
* @throws Exception
*/
void deleteBoard(BoardVO boardVO) throws Exception;
}
/////////////////////////////////////////////////////
// IBoardDAO.java
/////////////////////////////////////////////////////
package core.board;
import java.util.*;
public interface IBoardDAO {
/**
* 게시물 목록조회(주제검색)
* @param BoardVO
* @return Collection<boardVO>)
* @throws Exception
*/
BoardVO getBoard(BoardVO vo) throws Exception;
/**
* 게시물 목록조회(내용검색)
* @param BoardVO
* @return Collection<boardVO>)
* @throws Exception
*/
BoardVO getBoardCountByContents(BoardVO vo) throws Exception;
/**
* 게시물 조회
* @param BoardVO
* @return BoardVO
* @throws Exception
*/
BoardVO getBoardCountByTitle(BoardVO vo) throws Exception;
/**
* 게시물 건수 조회(주제검색)
* @param BoardVO
* @return BoardVO
* @throws Exception
*/
Collection getBoardListByContents(BoardVO vo) throws Exception;
/**
* 게시물 건수 조회(내용검색)
* @param BoardVO
* @return BoardVO
* @throws Exception
*/
Collection getBoardListByTitle(BoardVO vo) throws Exception;
/**
* 게시물 건수 최대값 채번
* @param BoardVO
* @return BoardVO
* @throws Exception
*/
BoardVO getMaxBoardSn() throws Exception;
/**
* 게시물 입력
* @param BoardVO
* @return void
* @throws Exception
*/
void insertBoard(BoardVO vo) throws Exception;
/**
* 게시물 수정
* @param BoardVO
* @return void
* @throws Exception
*/
void updateBoard(BoardVO boardVO) throws Exception;
/**
* 게시물 삭제
* @param BoardVO
* @return void
* @throws Exception
*/
void deleteBoard(BoardVO boardVO) throws Exception;
}
/////////////////////////////////////////////////////
// classes/core/board/BoardDAO.xml
/////////////////////////////////////////////////////
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "http://www.ibatis.com/dtd/sql-map-2.dtd">
<sqlMap namespace="board">
<!-- ======================================= -->
<!-- =============getBoardCount============= -->
<!-- ======================================= -->
<resultMap id="BoardCount" class="core.board.BoardVO">
<result property="count" column="count"/>
</resultMap>
<select id="getBoardCountByTitle" resultMap="BoardCount">
<![CDATA[
SELECT COUNT(SN) AS COUNT
FROM BOARD
WHERE TITLE LIKE '%' || #keyword# || '%'
]]>
</select>
<select id="getBoardCountByContents" resultMap="BoardCount">
<![CDATA[
SELECT COUNT(SN) AS COUNT
FROM BOARD
WHERE CONTENTS LIKE '%' || #keyword# || '%'
]]>
</select>
<!-- ====================================== -->
<!-- ============ getBoardList ============ -->
<!-- ====================================== -->
<resultMap id="BoardList" class="core.board.BoardVO">
<result property="sn" column="SN"/>
<result property="title" column="TITLE"/>
<result property="writer" column="WRITER"/>
</resultMap>
<select id="getBoardListByTitle" resultMap="BoardList">
<![CDATA[
SELECT *
FROM (SELECT ROW_NUMBER() OVER(ORDER BY SN DESC) BOARD_INDEX
, SN
, TITLE
, WRITER
FROM BOARD
WHERE TITLE LIKE '%' || #keyword# || '%')
WHERE BOARD_INDEX BETWEEN (TO_NUMBER(#page#) * 10 - 9) AND (TO_NUMBER(#page#) * 10)
]]>
</select>
<select id="getBoardListByContents" resultMap="BoardList">
<![CDATA[
SELECT *
FROM (SELECT ROW_NUMBER() OVER(ORDER BY SN DESC) BOARD_INDEX
, SN
, TITLE
, WRITER
FROM BOARD
WHERE CONTENTS LIKE '%' || #keyword# || '%')
WHERE BOARD_INDEX BETWEEN (TO_NUMBER(#page#) * 10 - 9) AND (TO_NUMBER(#page#) * 10)
]]>
</select>
<!-- ================================== -->
<!-- ============ getBoard ============ -->
<!-- ================================== -->
<resultMap id="Board" class="core.board.BoardVO">
<result property="sn" column="SN"/>
<result property="title" column="TITLE"/>
<result property="writer" column="WRITER"/>
<result property="contents" column="CONTENTS"/>
</resultMap>
<select id="getBoard" resultMap="Board">
<![CDATA[
SELECT SN
, TITLE
, WRITER
, CONTENTS
FROM BOARD
WHERE SN = #sn#
]]>
</select>
<!-- ================================== -->
<!-- ============ getTitle ============ -->
<!-- ================================== -->
<resultMap id="Board" class="core.board.BoardVO">
<result property="title" column="TITLE"/>
</resultMap>
<select id="getTitle" resultMap="Board">
<![CDATA[
SELECT TITLE
FROM (SELECT TITLE
, ROWNUM AS COUNT
FROM BOARD
WHERE TITLE LIKE #title# || '%')
WHERE COUNT < 10
]]>
</select>
<resultMap id="maxBoardSn" class="core.board.BoardVO">
<result property="sn" column="SN"/>
</resultMap>
<select id="getMaxBoardSn" resultMap="maxBoardSn">
<![CDATA[
SELECT DECODE(MAX(SN), NULL, 1
, MAX(SN) + 1) AS SN
FROM BOARD
]]>
</select>
<insert id="insertBoard" parameterClass="core.board.BoardVO">
<![CDATA[
INSERT INTO BOARD(SN
, TITLE
, WRITER
, CONTENTS)
VALUES (#sn#
, #title#
, #writer#
, #contents#)
]]>
</insert>
<update id="updateBoard" parameterClass="core.board.BoardVO">
<![CDATA[
UPDATE BOARD
SET TITLE = #title#
, CONTENTS = #contents#
WHERE SN = #sn#
]]>
</update>
<delete id="deleteBoard" parameterClass="core.board.BoardVO">
<![CDATA[
DELETE BOARD
WHERE SN = #sn#
]]>
</delete>
</sqlMap>
댓글 없음:
댓글 쓰기