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.MemoDao; |
---|
11 |
import org.springframework.samples.kyuriboard.domain.Memo; |
---|
12 |
|
---|
13 |
/** |
---|
14 |
* @author DAMI(archy712@naver.com) |
---|
15 |
* |
---|
16 |
*/ |
---|
17 |
public class SqlMapMemoDao extends SqlMapClientDaoSupport implements MemoDao { |
---|
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.MemoDao#deleteMemo(int) |
---|
27 |
*/ |
---|
28 |
public void deleteMemo(int memoId) throws DataAccessException { |
---|
29 |
// TODO Auto-generated method stub |
---|
30 |
Object parameterObject = new Integer(memoId); |
---|
31 |
getSqlMapClientTemplate().delete("deleteMemo", parameterObject); |
---|
32 |
} |
---|
33 |
|
---|
34 |
/* (non-Javadoc) |
---|
35 |
* @see org.springframework.samples.kyuriboard.dao.MemoDao#getMemoByMemoId(int) |
---|
36 |
*/ |
---|
37 |
public Memo getMemoByMemoId(int memoId) throws DataAccessException { |
---|
38 |
// TODO Auto-generated method stub |
---|
39 |
Object parameterObject = new Integer(memoId); |
---|
40 |
return (Memo) getSqlMapClientTemplate().queryForObject("getMemoByMemoId", parameterObject); |
---|
41 |
} |
---|
42 |
|
---|
43 |
/* (non-Javadoc) |
---|
44 |
* @see org.springframework.samples.kyuriboard.dao.MemoDao#getMemoListByBoardId(int) |
---|
45 |
*/ |
---|
46 |
public List getMemoListByBoardId(int boardId) throws DataAccessException { |
---|
47 |
// TODO Auto-generated method stub |
---|
48 |
Object parameterObject = new Integer(boardId); |
---|
49 |
return getSqlMapClientTemplate().queryForList("getMemoListByBoardId", parameterObject); |
---|
50 |
} |
---|
51 |
|
---|
52 |
/* (non-Javadoc) |
---|
53 |
* @see org.springframework.samples.kyuriboard.dao.MemoDao#insertMemo(org.springframework.samples.kyuriboard.domain.Memo) |
---|
54 |
*/ |
---|
55 |
public void insertMemo(Memo memo) throws DataAccessException { |
---|
56 |
// TODO Auto-generated method stub |
---|
57 |
memo.setMemoId(this.sequenceDao.getNextId("memoid")); |
---|
58 |
getSqlMapClientTemplate().insert("insertMemo", memo); |
---|
59 |
} |
---|
60 |
|
---|
61 |
/* (non-Javadoc) |
---|
62 |
* @see org.springframework.samples.kyuriboard.dao.MemoDao#updateMemo(org.springframework.samples.kyuriboard.domain.Memo) |
---|
63 |
*/ |
---|
64 |
public void updateMemo(Memo memo) throws DataAccessException { |
---|
65 |
// TODO Auto-generated method stub |
---|
66 |
getSqlMapClientTemplate().update("updateMemo", memo); |
---|
67 |
} |
---|
68 |
|
---|
69 |
public void deleteMemoByBoardId(int boardId) throws DataAccessException { |
---|
70 |
// TODO Auto-generated method stub |
---|
71 |
Object parameterObject = new Integer(boardId); |
---|
72 |
getSqlMapClientTemplate().update("deleteMemoByBoardId", parameterObject); |
---|
73 |
} |
---|
74 |
|
---|
75 |
} |
---|