() { {this.add((new org.apache.ibatis.mapping.ResultMap.Builder(com.culturalCenter.placeManage.mapper.SqlMapper.MSUtils.this.configuration, \"defaultResultMap\new ArrayList(0))).build()); }
}).build();
this.configuration.addMappedStatement(ms); }
private String select(String sql) {
String msId = this.newMsId(sql, SqlCommandType.SELECT); if (this.hasMappedStatement(msId)) { return msId; } else {
StaticSqlSource sqlSource = new StaticSqlSource(this.configuration, sql); this.newSelectMappedStatement(msId, sqlSource, Map.class); return msId; } }
private String selectDynamic(String sql, Class> parameterType) {
String msId = this.newMsId(sql + parameterType, SqlCommandType.SELECT); if (this.hasMappedStatement(msId)) {
return msId; } else {
SqlSource sqlSource = this.languageDriver.createSqlSource(this.configuration, sql, parameterType); this.newSelectMappedStatement(msId, sqlSource, Map.class); return msId; } }
private String select(String sql, Class> resultType) {
String msId = this.newMsId(resultType + sql, SqlCommandType.SELECT); if (this.hasMappedStatement(msId)) { return msId; } else {
StaticSqlSource sqlSource = new StaticSqlSource(this.configuration, sql); this.newSelectMappedStatement(msId, sqlSource, resultType); return msId; } }
private String selectDynamic(String sql, Class> parameterType, Class> resultType) {
String msId = this.newMsId(resultType + sql + parameterType, SqlCommandType.SELECT); if (this.hasMappedStatement(msId)) { return msId; } else {
SqlSource sqlSource = this.languageDriver.createSqlSource(this.configuration, sql, parameterType); this.newSelectMappedStatement(msId, sqlSource, resultType); return msId; } }
private String insert(String sql) {
String msId = this.newMsId(sql, SqlCommandType.INSERT); if (this.hasMappedStatement(msId)) { return msId; } else {
StaticSqlSource sqlSource = new StaticSqlSource(this.configuration, sql);
this.newUpdateMappedStatement(msId, sqlSource, SqlCommandType.INSERT); return msId; } }
private String insertDynamic(String sql, Class> parameterType) {
String msId = this.newMsId(sql + parameterType, SqlCommandType.INSERT); if (this.hasMappedStatement(msId)) { return msId; } else {
SqlSource sqlSource = this.languageDriver.createSqlSource(this.configuration, sql, parameterType); this.newUpdateMappedStatement(msId, sqlSource, SqlCommandType.INSERT); return msId; } }
private String update(String sql) {
String msId = this.newMsId(sql, SqlCommandType.UPDATE); if (this.hasMappedStatement(msId)) { return msId; } else {
StaticSqlSource sqlSource = new StaticSqlSource(this.configuration, sql);
this.newUpdateMappedStatement(msId, sqlSource, SqlCommandType.UPDATE); return msId; } }
private String updateDynamic(String sql, Class> parameterType) {
String msId = this.newMsId(sql + parameterType, SqlCommandType.UPDATE); if (this.hasMappedStatement(msId)) { return msId; } else {
SqlSource sqlSource = this.languageDriver.createSqlSource(this.configuration, sql, parameterType); this.newUpdateMappedStatement(msId, sqlSource, SqlCommandType.UPDATE); return msId; } }
private String delete(String sql) {
String msId = this.newMsId(sql, SqlCommandType.DELETE); if (this.hasMappedStatement(msId)) { return msId; } else {
StaticSqlSource sqlSource = new StaticSqlSource(this.configuration, sql);
this.newUpdateMappedStatement(msId, sqlSource, SqlCommandType.DELETE); return msId; } }
private String deleteDynamic(String sql, Class> parameterType) {
String msId = this.newMsId(sql + parameterType, SqlCommandType.DELETE); if (this.hasMappedStatement(msId)) { return msId; } else {
SqlSource sqlSource = this.languageDriver.createSqlSource(this.configuration, sql, parameterType); this.newUpdateMappedStatement(msId, sqlSource, SqlCommandType.DELETE); return msId; } } }}
然后做⼀个 数据连接⼯⼚类
SqlSessionFactoryConfig/**
* @author chaild
* @Date 2020年6⽉23⽇18:25:22 * 创建SQL连接⼯⼚类 * */
@Configuration
public class SqlSessionFactoryConfig { @javax.annotation.Resource DruidDataSource dataSource;
@Bean @Primary
public SqlSessionFactory sqlSessionFactory() throws Exception { SqlSessionFactoryBean bean = new SqlSessionFactoryBean(); bean.setDataSource(dataSource);//更多参数请⾃⾏注⼊ bean.setPlugins(new Interceptor[]{new SqlInterceptor()});
Resource[] resources = new PathMatchingResourcePatternResolver() .getResources(\"classpath*:mapper/*.xml\"); bean.setMapperLocations(resources); return bean.getObject(); }}
使⽤⽰例:
@Autowired
private SqlMapper sqlMapper;###selectList
//查询,返回List