
mybatis
kong-kong
记录流水账
展开
-
解析生成MappedStatement
功能就是把1条<select></select> 或 <insert/> 等变成1个MappedStatementxml方式XMLStatementBuilder解析xml文件中各个节点,比如<select/>、<insert/>、<update/>、<delete/>节点,内部会使用XMLScriptBuilder处理节点的sql部分,每个节点(<select/>、<insert.原创 2020-12-01 19:30:12 · 918 阅读 · 0 评论 -
StrictMap
protected static class StrictMap<V> extends HashMap<String, V> {}putpublic V put(String key, V value) { if (containsKey(key)) { //key: com.kq.mybatis.mapper.AccountMapper.getAccountList 完整的key,如果重复就会报错 throw new Illegal...原创 2020-12-01 19:24:10 · 1401 阅读 · 0 评论 -
@MapperScan扫描
@MapperScan@MapperScan({"com.kq.mybatis.mapper","com.kq.mybatis1.mapper"})public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) { AnnotationAttributes mapperScanAttrs = AnnotationAttribute原创 2020-09-25 23:33:05 · 13861 阅读 · 0 评论 -
mybatis设置参数
简化流程图PreparedStatement设置如果是PreparedStatement,则最终都是调用PreparedStatement的setXXX方法PreparedStatement pstmt = con.prepareStatement("UPDATE EMPLOYEES SET AGE=? WHERE ID = ?"); pstmt.setInt(1, 20);pstmt.setInt(2, 11.原创 2020-09-24 21:06:19 · 881 阅读 · 0 评论 -
MetaObject
MapWrapper@Testpublic void testMap(){ Map<String,Object> map = new HashMap(); map.put("param1","hello"); Account account = new Account(); account.setId(8L); account.setUsername("admin"); Teacher teacher = new Teacher(); teacher.setId(1L)原创 2020-09-24 00:11:09 · 427 阅读 · 0 评论 -
Parameter获取实际参数名 -parameters
AccountMapperpublic interface AccountMapper { public void accountAdd(Long id, String username, Date createTime);}PTestpublic class PTest { public static void main(String[] args) throws Exception { Method method = AccountMappe.原创 2020-09-23 14:42:42 · 1656 阅读 · 3 评论 -
ParamNameResolver 参数名称解析器
本版本3.5.2* <li>aMethod(@Param("M") int a, @Param("N") int b) -> {{0, "M"}, {1, "N"}}</li>* <li>aMethod(int a, int b) -> {{0, "0"}, {1, "1"}}</li>* <li>aMethod(int a, RowBounds rb, int b) -> {{0, "0"},.原创 2020-09-22 19:30:09 · 807 阅读 · 0 评论 -
StatementHandler
类图RoutingStatementHandlerStatementHandler的路由类处理具体的业务的都是delegatepublic class RoutingStatementHandler implements StatementHandler { private final StatementHandler delegate; public RoutingStatementHandler(Executor executor, MappedStatemen.原创 2020-09-22 18:01:38 · 573 阅读 · 0 评论 -
mybatis-jdbc日志代理类
BaseExecutorprotected Connection getConnection(Log statementLog) throws SQLException { Connection connection = transaction.getConnection(); if (statementLog.isDebugEnabled()) { return ConnectionLogger.newInstance(connection, statementLog,原创 2020-09-22 18:01:09 · 442 阅读 · 0 评论 -
Mybatis执行select流程
AccountMapper从图中可知,AccountMapper的代理就是1个MapperProxy主线流程MapperProxypublic class MapperProxy<T> implements InvocationHandler, Serializable { private static final long serialVersionUID = -6424540398559729838L; private final SqlSes..原创 2020-09-21 19:33:08 · 449 阅读 · 0 评论 -
generatorConfig.xml 配置
http://mybatis.org/generator/configreference/xmlconfig.html<!-- 引入配置文件 --><properties resource="application.properties" /><!-- 指定具体的值 --><jdbcConnection driverClass="oracle.jdbc.driver.OracleDriver" connectionURL="j..原创 2020-07-23 19:03:20 · 1059 阅读 · 0 评论 -
MyBatis-Spring 入门
MyBatis-Spring MyBatis Spring 框架 Spring Batch Java 2.0 3.5+ 5.0+ 4.0+ Java 8+ 1.3 3.4+ 3.2.2+ 2.1+ Java 6+ maven 依赖<dependency> <groupId&g...转载 2019-10-12 15:16:36 · 346 阅读 · 0 评论 -
自己实现通过mapper取sql
public class DomUtil { protected static final Logger logger = LoggerFactory.getLogger(DomUtil.class); final static Map<String, Map<String,String>> xmlDataMap = new HashMa...原创 2019-09-26 14:26:20 · 585 阅读 · 1 评论 -
mybatis 1对多查询
单值:<resultMap id="articleSearchResult" type="com.VoArticleSetting"> <collection property="orgs" javaType="ArrayList" column="id" ofType="com.vo.VoIdAndName" select="com.mapper.SOrgVi...原创 2019-06-05 11:13:56 · 494 阅读 · 0 评论 -
bind
bind例子:num = num+1 例子 <bind name="num" value="0" /> <foreach collection="list" item="ss" index="index" separator=","> <if test="ss.orderByField == 'soldAmount'"&g...原创 2019-05-14 19:12:43 · 287 阅读 · 0 评论 -
mybatis语法
list判断<if test="filterNames!=null and filterNames.size()>0"></if>foreach<foreach collection="filterNames" item="v" separator="," open="(" close=&q原创 2018-11-16 22:16:45 · 334 阅读 · 0 评论