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);
}
标签:SqlCommandType,sql,mybatis,new,sqlRunner,type
From: https://www.cnblogs.com/rbcd/p/16915279.html