root/nextboard/src/org/springframework/samples/kyuriboard/dao/ibatis/SqlMapSequenceDao.java

리비전 3, 1.1 kB (mefour에 의해 체크인됨, 16 년 전)

ASSIGNED - # 1: 인큐페이터 사이트를 위한 개념 정립
http://221.150.127.106:8081/projects/hubproject/ticket/1

Line 
1 /**
2  *
3  */
4 package org.springframework.samples.kyuriboard.dao.ibatis;
5
6 import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
7 import org.springframework.dao.DataAccessException;
8 import org.springframework.dao.DataRetrievalFailureException;
9
10 /**
11  * @author DAMI(archy712@naver.com)
12  *
13  */
14 public class SqlMapSequenceDao extends SqlMapClientDaoSupport {
15        
16         /**
17          * 씨퀀스의 다음 ID를 얻어오고, 해당 시퀀스의 번호를 1 증가 시킨다.
18          * @param name 해당 시퀀스 명
19          * @return 시퀀스의 증가된 값
20          * @throws DataAccessException 해당 시퀀스 Row를 찾을 수 없슴.
21          */
22         public int getNextId(String name) throws DataAccessException {
23                 Sequence sequence = new Sequence(name, -1);
24                 sequence = (Sequence) getSqlMapClientTemplate().queryForObject("getSequence", sequence);
25                 if (sequence == null) {
26                         throw new DataRetrievalFailureException("Could not get next value of sequence [" + name + "] : sequence does not exist");
27                 }
28                 Object parameterObject = new Sequence(name, sequence.getNextId() + 1);
29                 getSqlMapClientTemplate().update("updateSequence", parameterObject, 1);
30                 return sequence.getNextId();
31         }
32
33 }
참고: 소스 브라우저를 사용하면서 도움이 필요하다면, TracBrowser를 참고하십시오.