일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- Mac
- IntelliJ
- Windows 10
- 단축키
- resource
- 줄바꿈 문자
- find
- port
- import
- netsh
- xargs
- Source
- tomcat
- vscode
- Eclipse
- bash
- grep
- maVen
- profile
- VirtualBox
- GIT
- Quartz
- ssh
- context
- lsof
- plugin
- JavaScript
- web.xml
- 네트워크
- Windows
- 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 |