1 |
/** |
---|
2 |
* |
---|
3 |
*/ |
---|
4 |
package org.springframework.samples.kyuriboard.dao.ibatis; |
---|
5 |
|
---|
6 |
import java.util.List; |
---|
7 |
|
---|
8 |
import org.springframework.dao.DataAccessException; |
---|
9 |
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport; |
---|
10 |
import org.springframework.samples.kyuriboard.dao.BoardDao; |
---|
11 |
import org.springframework.samples.kyuriboard.domain.Board; |
---|
12 |
|
---|
13 |
/** |
---|
14 |
* @author DAMI(archy712@naver.com) |
---|
15 |
* |
---|
16 |
*/ |
---|
17 |
public class SqlMapBoardDao extends SqlMapClientDaoSupport implements BoardDao { |
---|
18 |
|
---|
19 |
private SqlMapSequenceDao sequenceDao; |
---|
20 |
|
---|
21 |
public void setSequenceDao(SqlMapSequenceDao sequenceDao) { |
---|
22 |
this.sequenceDao = sequenceDao; |
---|
23 |
} |
---|
24 |
|
---|
25 |
/* (non-Javadoc) |
---|
26 |
* @see org.springframework.samples.kyuriboard.dao.BoardDao#deleteBoard(int) |
---|
27 |
*/ |
---|
28 |
public void deleteBoard(int boardId) throws DataAccessException { |
---|
29 |
// TODO Auto-generated method stub |
---|
30 |
Object parameterObject = new Integer(boardId); |
---|
31 |
getSqlMapClientTemplate().delete("deleteBoard", parameterObject); |
---|
32 |
} |
---|
33 |
|
---|
34 |
/* (non-Javadoc) |
---|
35 |
* @see org.springframework.samples.kyuriboard.dao.BoardDao#getBoardByBoardId(int) |
---|
36 |
*/ |
---|
37 |
public Board getBoardByBoardId(int boardId) throws DataAccessException { |
---|
38 |
// TODO Auto-generated method stub |
---|
39 |
Object parameterObject = new Integer(boardId); |
---|
40 |
return (Board) getSqlMapClientTemplate().queryForObject("getBoardByBoardId", parameterObject); |
---|
41 |
} |
---|
42 |
|
---|
43 |
/* (non-Javadoc) |
---|
44 |
* @see org.springframework.samples.kyuriboard.dao.BoardDao#getBoardList() |
---|
45 |
*/ |
---|
46 |
public List getBoardList() throws DataAccessException { |
---|
47 |
// TODO Auto-generated method stub |
---|
48 |
return getSqlMapClientTemplate().queryForList("getBoardList"); |
---|
49 |
} |
---|
50 |
|
---|
51 |
/* (non-Javadoc) |
---|
52 |
* @see org.springframework.samples.kyuriboard.dao.BoardDao#getBoardListByTitle(java.lang.String) |
---|
53 |
*/ |
---|
54 |
public List getBoardListByTitle(String title) throws DataAccessException { |
---|
55 |
// TODO Auto-generated method stub |
---|
56 |
return getSqlMapClientTemplate().queryForList("getBoardListByTitle", title); |
---|
57 |
} |
---|
58 |
|
---|
59 |
/* (non-Javadoc) |
---|
60 |
* @see org.springframework.samples.kyuriboard.dao.BoardDao#getBoardListByUserId(java.lang.String) |
---|
61 |
*/ |
---|
62 |
public List getBoardListByUserId(String userId) throws DataAccessException { |
---|
63 |
// TODO Auto-generated method stub |
---|
64 |
return getSqlMapClientTemplate().queryForList("getBoardListByUserId", userId); |
---|
65 |
} |
---|
66 |
|
---|
67 |
/* (non-Javadoc) |
---|
68 |
* @see org.springframework.samples.kyuriboard.dao.BoardDao#getBoardListByUserName(java.lang.String) |
---|
69 |
*/ |
---|
70 |
public List getBoardListByUserName(String userName) |
---|
71 |
throws DataAccessException { |
---|
72 |
// TODO Auto-generated method stub |
---|
73 |
return getSqlMapClientTemplate().queryForList("getBoardListByUserName", userName); |
---|
74 |
} |
---|
75 |
|
---|
76 |
/* (non-Javadoc) |
---|
77 |
* @see org.springframework.samples.kyuriboard.dao.BoardDao#insertBoard(org.springframework.samples.kyuriboard.domain.Board) |
---|
78 |
*/ |
---|
79 |
public void insertBoard(Board board) throws DataAccessException { |
---|
80 |
// TODO Auto-generated method stub |
---|
81 |
board.setBoardId(this.sequenceDao.getNextId("boardid")); |
---|
82 |
getSqlMapClientTemplate().insert("insertBoard", board); |
---|
83 |
} |
---|
84 |
|
---|
85 |
/* (non-Javadoc) |
---|
86 |
* @see org.springframework.samples.kyuriboard.dao.BoardDao#updateBoard(org.springframework.samples.kyuriboard.domain.Board) |
---|
87 |
*/ |
---|
88 |
public void updateBoard(Board board) throws DataAccessException { |
---|
89 |
// TODO Auto-generated method stub |
---|
90 |
getSqlMapClientTemplate().update("updateBoard", board); |
---|
91 |
} |
---|
92 |
|
---|
93 |
|
---|
94 |
|
---|
95 |
} |
---|