|
@@ -8,17 +8,14 @@ import org.apache.commons.lang3.StringUtils;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
-import org.springframework.transaction.TransactionStatus;
|
|
|
|
-import org.springframework.transaction.support.TransactionCallbackWithoutResult;
|
|
|
|
-import org.springframework.transaction.support.TransactionTemplate;
|
|
|
|
|
|
|
|
-// @DataUpgradeVersion("1.0.5")
|
|
|
|
|
|
+@DataUpgradeVersion("1.0.5")
|
|
public class DataUpgrade_1_0_5 implements DataUpgradeService {
|
|
public class DataUpgrade_1_0_5 implements DataUpgradeService {
|
|
|
|
|
|
private static final Logger log = LoggerFactory.getLogger(DataUpgrade_1_0_5.class);
|
|
private static final Logger log = LoggerFactory.getLogger(DataUpgrade_1_0_5.class);
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public void process(JdbcTemplate jdbcTemplate, TransactionTemplate transactionTemplate) throws Exception {
|
|
|
|
|
|
+ public void process(JdbcTemplate jdbcTemplate) throws Exception {
|
|
log.info("process...");
|
|
log.info("process...");
|
|
|
|
|
|
String[] sqlList = StringUtils.split(ResourceFileHelper.readContent("upgrade/1.0.5.sql"), ";");
|
|
String[] sqlList = StringUtils.split(ResourceFileHelper.readContent("upgrade/1.0.5.sql"), ";");
|
|
@@ -26,26 +23,14 @@ public class DataUpgrade_1_0_5 implements DataUpgradeService {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- transactionTemplate.execute(new TransactionCallbackWithoutResult() {
|
|
|
|
- @Override
|
|
|
|
- protected void doInTransactionWithoutResult(TransactionStatus status) {
|
|
|
|
- try {
|
|
|
|
- for (String sql : sqlList) {
|
|
|
|
- if (StringUtils.isBlank(sql)) {
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- log.info(sql);
|
|
|
|
- jdbcTemplate.execute(sql);
|
|
|
|
- }
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- // DML-SQL语句支持事务,执行失败时触发自动回滚。
|
|
|
|
- status.setRollbackOnly();
|
|
|
|
- // DDL-SQL语句不支持事务,执行失败时请采用其它补偿机制回滚!!!
|
|
|
|
- throw new RuntimeException("SQL语句执行异常!", e);
|
|
|
|
- }
|
|
|
|
|
|
+ for (String sql : sqlList) {
|
|
|
|
+ if (StringUtils.isBlank(sql)) {
|
|
|
|
+ continue;
|
|
}
|
|
}
|
|
- });
|
|
|
|
|
|
+
|
|
|
|
+ log.info(sql);
|
|
|
|
+ jdbcTemplate.execute(sql);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|