일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
- vscode
- 단축키
- 줄바꿈 문자
- bash
- maVen
- resource
- IntelliJ
- VirtualBox
- tomcat
- grep
- Eclipse
- Mac
- profile
- port
- netsh
- context
- Windows 10
- ssh
- lsof
- Source
- Windows
- xargs
- web.xml
- find
- import
- GIT
- 네트워크
- Quartz
- plugin
- JavaScript
- Today
- Total
develog
REQUIRES_NEW 본문
public class TestService {
@Autowired
private TestDao testDao;
@Autowired
private ApplicationContext applicationContext;
public void insertAll() {
for (int i = 1; i <= 4; i++) {
try {
String ret = eachInsert(i);
System.out.println(i + ", OK, " + ret);
} catch (Exception e) {
System.out.println(i + ", ERR, " + e.getMessage());
}
}
}
public String insert(final int num) {
String ret = null;
PlatformTransactionManager transactionManager = (PlatformTransactionManager) applicationContext.getBean("transactionManager");
TransactionTemplate transactionTemplate = new TransactionTemplate(transactionManager);
transactionTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
ret = (String) transactionTemplate.execute(new TransactionCallback() {
public String doInTransaction(TransactionStatus status) {
int cnt = testDao.insert(num);
if (num % 2 == 0) {
throw new RuntimeException("TEST ERR!");
}
return String.valueOf(cnt);
}
});
return ret;
}
}
'Dev > Java' 카테고리의 다른 글
[web-app spec] servlet, tomcat, java, web.xml version (0) | 2013.07.25 |
---|---|
servlet, jsp, tomcat, java 버전별 비교 (0) | 2013.07.24 |
jndi (0) | 2013.07.18 |
template, callback (0) | 2013.07.17 |
AsyncHttpClient (0) | 2013.07.11 |