package org.ph.txex.mapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
public interface TxExMapper {
@Insert("insert into tbl_tx1 (num, codevalue) values (seq_tx.nextval, #{codeValue})")
public void insertMain(String codeValue)throws Exception;
@Insert("insert into tbl_tx2 (num, strValue) values (seq_tx.nextval, #{strValue})")
public void insertSub(String strValue)throws Exception;
@Update("update tbl_tx2 set strvalue = strvalue||#{appendValue} where num = #{num} ")
public void update1(@Param("num") Integer num, @Param("appendValue")String appendValue)throws Exception;
}
package org.ph.txex.service;
import javax.inject.Inject;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.ph.txex.mapper.TxExMapper;
@Service
@Transactional
public class TxExService {
@Inject
TxExMapper mapper;
@Transactional(propagation = Propagation.REQUIRED)
public void addData(String codeValue, String strValue) throws Exception {
mapper.insertMain(codeValue);
mapper.insertSub(strValue);
}
public void updateData(Integer num, String value) throws Exception {
mapper.insertMain(value);
mapper.update1(num, value);
}
}
package org.ph.txex.test;
import static org.junit.Assert.fail;
import javax.inject.Inject;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.ph.txex.service.TxExService;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations ={"file:src/main/webapp/WEB-INF/spring/**/*.xml"})
public class TxExServiceTest {
@Inject
TxExService service;
@Test
public void testInsert() throws Exception{
String codeValue = "이이이3";
String strValue = "이이이3";
service.addData(codeValue, strValue);
}
@Test
public void testUpdate() throws Exception{
Integer num = 2;
String strValue = "zzz";
service.updateData(num, strValue);
}
}
'코딩 > WEB' 카테고리의 다른 글
에러 Error 심각: Allocate exception for servlet Controller (0) | 2014.11.07 |
---|---|
Web : 글 보기 게시판에 댓글 보는 기능 붙여주기 (ajax+JSON) (0) | 2014.11.06 |
Spring - Cookie Filter 예제 (0) | 2014.10.17 |
Spring 설정 -- 3 AOP 설정 (0) | 2014.10.15 |
Spring 설정 -- 1 (0) | 2014.10.14 |