mybatis代理类创建
DefaultSqlSession #getMapper
MapperRegistry #getMapper
MapperProxyFactory #newInstance
Proxy.newProxyInstance(, , new MapperProxy(new MapperMethod()));
1、pg、dm、mysql 可以直接使用mybatis配置:
useGeneratedKeys="true"keyProperty="id"keyColumn="id"
2、oracle时,需要使用
<selectKeyresultType="int"keyProperty="id"order="BEFORE"databaseId="postgres">
3、工具类使用
String sql = new SQL().SELECT().FROM(tableName).toString();
SqlRunner sqlRunner = new SqlRunner(conn);
if (SqlCommandType.DELETE.equals(type)) {
sqlRunner.delete(sql, objectArr);
} else if (SqlCommandType.UPDATE.equals(type)) {
sqlRunner.update(sql, objectArr);
} else if (SqlCommandType.INSERT.equals(type)) {
sqlRunner.insert(sql, objectArr);
}
mybatis自定义类型
继承BaseTypeHandler<T>
@MappedTypes({Object.class})
public class A<T extends Object> extends BaseTypeHandler<T> {
}
slf4j框架自动创建logs目录
1、logback-spring.xml文件使用默认的或者指定的
若需要指定时配置参数为logging.config = config/logback-spring.xml
2、在日志文件logback-spring.xml中设置日志文件路径:logDir
slf4j框架打印mybatis的sql语句
mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
mybatis.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
logging.level.org=off
logging.level.druid=off
logging.level.springfox=off
logging.level.com.**.mapper=debug
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)