cn.flood.cloud.seata.idempotent.JdbcResultHolder Maven / Gradle / Ivy
package cn.flood.cloud.seata.idempotent;
import cn.flood.base.core.Func;
import cn.flood.base.core.lang.StringUtils;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.sql.DataSource;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.util.Assert;
/**
* @author mmdai
* @version 1.0
* @date 2022/5/6 15:44
*/
public class JdbcResultHolder implements ResultHolder {
/**
* sql
*/
private static final String UPDATE_FIELDS = "action_class, xid, context";
/**
* 插入
*/
private static final String SQL_INSERT =
"insert into seata_tcc (" + UPDATE_FIELDS + ") values (?, ?, ?) ";
/**
* 删除
*/
private static final String SQL_DELETE_BY_XID = "delete from seata_tcc where action_class = ? and xid = ? ";
/**
* 查询
*/
private static final String SQL_SELECT_BY_XID = "select count(1) from seata_tcc where action_class = ? and xid = ? ";
private final JdbcTemplate jdbcTemplate;
public JdbcResultHolder(DataSource dataSource) {
Assert.notNull(dataSource, "DataSource required");
this.jdbcTemplate = new JdbcTemplate(dataSource);
}
/**
* @param actionClass
* @param xid
* @param context
*/
@Override
public void setResult(String actionClass, String xid, String context) {
List
© 2015 - 2024 Weber Informatics LLC | Privacy Policy