MyBatis 自定义 typeHandler

自定义typeHandler

对于自定义typeHandler来说,需要在配置文件中注册typeHandlers 然后需要实现TypeHandler接口,
一个例子
首先编写调度的处理类

package com.ming.MyBatis;


import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.TypeHandler;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class StringTypeHandler  implements TypeHandler<String> {
    private static Logger logger = LogManager.getLogger();

    /**
     * 对预编译的Sql语句进行设置的时候,
     * @param ps
     * @param i
     * @param parameter
     * @param jdbcType
     * @throws SQLException
     */
    @Override
    public void setParameter(PreparedStatement ps, int i, String parameter, JdbcType jdbcType) throws SQLException {
        logger.info("使用TypeHandler");
        // 设置预编译的sql对象,的string
        ps.setString(i, parameter);
    }

    /**
     * 获得结果的时候,获取到列名的时候,调度此方法
     * @param rs
     * @param columnName
     * @return
     * @throws SQLException
     */
    @Override
    public String getResult(ResultSet rs, String columnName) throws SQLException {
        logger.info("使用自定义类型,结果获取列名字符串");
        return rs.getString(columnName);
    }

    /**
     * 获取结果集中的index
     * @param rs
     * @param columnIndex
     * @return
     * @throws SQLException
     */
    @Override
    public String getResult(ResultSet rs, int columnIndex) throws SQLException {
        logger.info("在结果集中获取columnIndex");
        return rs.getString(columnIndex);
    }

    /**
     * 获取结果集中的下标对应的字符串
     * @param cs
     * @param columnIndex
     * @return
     * @throws SQLException
     */
    @Override
    public String getResult(CallableStatement cs, int columnIndex) throws SQLException {
        logger.info("结果集中,下标获取到字符串");
        return cs.getString(columnIndex);
    }
}

再次编写配置文件

    <typeHandlers>
        <typeHandler jdbcType="VARCHAR" javaType="string" handler="com.ming.MyBatis.StringTypeHandler">
    </typeHandlers>

传入数据库的为的VARCHAR类型,javaType类型为string类型,调度的类为com.ming.MyBatis.StringTypeHandler
修改映射文件,说明那些需要对结果进行修改

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!-- 定义接口类 -->
<mapper namespace="com.ming.MyBatis.POJO.RoleMapper">
    <!-- id表示标签标识 type标识结果的返回类型,其中role为在配置文件中使用的别名 Role类 -->
    <resultMap type="role" id="roleMap">
        <!-- id为主键映射关系 其中数据库中的id为主键 -->
        <id column="id" property="id" javaType="int" jdbcType="INTEGER"/>
        <!-- result为其他基本数据类型和实体类之间的映射 映射关系为role_name 到 roleName之间的映射 数据类型为string到VARCHAR之间的映射关系 -->
        <result column="role_name" property="roleName" javaType="string" jdbcType="VARCHAR"/>
        <!-- 这里使用typeHandler表示遇到此处理集的时候,将会执行com.ming.MyBatis.StringTypeHandler -->
        <result column="note" property="note" typeHandler="com.ming.MyBatis.StringTypeHandler"/>
    </resultMap>
    
    <!-- 书写SQL语句 定义使用resultMap为roleMap-->
    <select id="getRole" parameterType="int" resultMap="roleMap">
        SELECT id, role_name, note FROM t_role4 WHERE id = #{id}
    </select>
    
</mapper>

其中传入的参数为int类型,由于结果中mybatis没有int类型,对应的是INTEGER类型,在mysql中两者类型相同,所以修改如上所示,表类型


1554124784598.remmina-2019-4-12-21-6-4.318709

书写index.jsp

<%@ page import="org.apache.ibatis.session.SqlSession" %>
<%@ page import="com.ming.Util.SqlSessionFactoryUtil" %>
<%@ page import="com.ming.MyBatis.POJO.RoleMapper" %>
<%@ page import="com.ming.MyBatis.POJO.Role" %>
<html>
<body>
<h2>Hello World!</h2>

<%
    long startTime = System.currentTimeMillis(); //获取开始时间
    SqlSession sqlSession = null;
    Role role = null;
    for(int i = 0; i < 10; i++) {
        try {
            sqlSession = SqlSessionFactoryUtil.openSqlSesion();
            RoleMapper roleMapper = sqlSession.getMapper(RoleMapper.class);
            role = roleMapper.getRole(100);
            sqlSession.commit();
        } catch (Exception e) {
            e.printStackTrace();
            sqlSession.rollback();
        } finally {
            if (sqlSession != null) {
                sqlSession.close();
            }
        }
    }
    long endTime = System.currentTimeMillis(); //获取结束时间

%>
<%=role.getNote()%>
</body>
</html>

已经查询成功

2019-04-13-05-08-47----

查看日志文件,日志文件已经输出相关信息

2019-04-13 05:03:33.181 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.openConnection(JdbcTransaction.java:136) - Opening JDBC Connection
2019-04-13 05:03:33.181 [DEBUG] org.apache.ibatis.datasource.pooled.PooledDataSource.popConnection(PooledDataSource.java:397) - Checked out connection 197673257 from pool.
2019-04-13 05:03:33.182 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.setDesiredAutoCommit(JdbcTransaction.java:100) - Setting autocommit to false on JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@bc84129]
2019-04-13 05:03:33.235 [DEBUG] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:143) - ==>  Preparing: SELECT id, role_name, note FROM t_role4 WHERE id = ? 
2019-04-13 05:03:33.236 [DEBUG] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:143) - ==> Parameters: 100(Integer)
2019-04-13 05:03:33.275 [INFO ] com.ming.MyBatis.StringTypeHandler.getResult(StringTypeHandler.java:48) - 使用自定义类型,结果获取列名字符串
2019-04-13 05:03:33.276 [INFO ] com.ming.MyBatis.StringTypeHandler.getResult(StringTypeHandler.java:48) - 使用自定义类型,结果获取列名字符串
2019-04-13 05:03:33.277 [DEBUG] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:143) - <==      Total: 1
2019-04-13 05:03:33.277 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.resetAutoCommit(JdbcTransaction.java:122) - Resetting autocommit to true on JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@bc84129]
2019-04-13 05:03:33.312 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.close(JdbcTransaction.java:90) - Closing JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@bc84129]
2019-04-13 05:03:33.312 [DEBUG] org.apache.ibatis.datasource.pooled.PooledDataSource.pushConnection(PooledDataSource.java:362) - Returned connection 197673257 to pool.
2019-04-13 05:03:33.313 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.openConnection(JdbcTransaction.java:136) - Opening JDBC Connection
2019-04-13 05:03:33.314 [DEBUG] org.apache.ibatis.datasource.pooled.PooledDataSource.popConnection(PooledDataSource.java:397) - Checked out connection 197673257 from pool.
2019-04-13 05:03:33.314 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.setDesiredAutoCommit(JdbcTransaction.java:100) - Setting autocommit to false on JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@bc84129]
2019-04-13 05:03:33.346 [DEBUG] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:143) - ==>  Preparing: SELECT id, role_name, note FROM t_role4 WHERE id = ? 
2019-04-13 05:03:33.348 [DEBUG] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:143) - ==> Parameters: 100(Integer)
2019-04-13 05:03:33.386 [INFO ] com.ming.MyBatis.StringTypeHandler.getResult(StringTypeHandler.java:48) - 使用自定义类型,结果获取列名字符串
2019-04-13 05:03:33.390 [INFO ] com.ming.MyBatis.StringTypeHandler.getResult(StringTypeHandler.java:48) - 使用自定义类型,结果获取列名字符串
2019-04-13 05:03:33.391 [DEBUG] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:143) - <==      Total: 1
2019-04-13 05:03:33.395 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.resetAutoCommit(JdbcTransaction.java:122) - Resetting autocommit to true on JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@bc84129]
2019-04-13 05:03:33.442 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.close(JdbcTransaction.java:90) - Closing JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@bc84129]
2019-04-13 05:03:33.443 [DEBUG] org.apache.ibatis.datasource.pooled.PooledDataSource.pushConnection(PooledDataSource.java:362) - Returned connection 197673257 to pool.
2019-04-13 05:03:33.443 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.openConnection(JdbcTransaction.java:136) - Opening JDBC Connection
2019-04-13 05:03:33.444 [DEBUG] org.apache.ibatis.datasource.pooled.PooledDataSource.popConnection(PooledDataSource.java:397) - Checked out connection 197673257 from pool.
2019-04-13 05:03:33.444 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.setDesiredAutoCommit(JdbcTransaction.java:100) - Setting autocommit to false on JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@bc84129]
2019-04-13 05:03:33.479 [DEBUG] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:143) - ==>  Preparing: SELECT id, role_name, note FROM t_role4 WHERE id = ? 
2019-04-13 05:03:33.480 [DEBUG] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:143) - ==> Parameters: 100(Integer)
2019-04-13 05:03:33.518 [INFO ] com.ming.MyBatis.StringTypeHandler.getResult(StringTypeHandler.java:48) - 使用自定义类型,结果获取列名字符串
2019-04-13 05:03:33.519 [INFO ] com.ming.MyBatis.StringTypeHandler.getResult(StringTypeHandler.java:48) - 使用自定义类型,结果获取列名字符串
2019-04-13 05:03:33.520 [DEBUG] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:143) - <==      Total: 1
2019-04-13 05:03:33.520 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.resetAutoCommit(JdbcTransaction.java:122) - Resetting autocommit to true on JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@bc84129]
2019-04-13 05:03:33.556 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.close(JdbcTransaction.java:90) - Closing JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@bc84129]
2019-04-13 05:03:33.557 [DEBUG] org.apache.ibatis.datasource.pooled.PooledDataSource.pushConnection(PooledDataSource.java:362) - Returned connection 197673257 to pool.
2019-04-13 05:03:33.558 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.openConnection(JdbcTransaction.java:136) - Opening JDBC Connection
2019-04-13 05:03:33.558 [DEBUG] org.apache.ibatis.datasource.pooled.PooledDataSource.popConnection(PooledDataSource.java:397) - Checked out connection 197673257 from pool.
2019-04-13 05:03:33.558 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.setDesiredAutoCommit(JdbcTransaction.java:100) - Setting autocommit to false on JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@bc84129]
2019-04-13 05:03:33.591 [DEBUG] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:143) - ==>  Preparing: SELECT id, role_name, note FROM t_role4 WHERE id = ? 
2019-04-13 05:03:33.592 [DEBUG] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:143) - ==> Parameters: 100(Integer)
2019-04-13 05:03:33.638 [INFO ] com.ming.MyBatis.StringTypeHandler.getResult(StringTypeHandler.java:48) - 使用自定义类型,结果获取列名字符串
2019-04-13 05:03:33.639 [INFO ] com.ming.MyBatis.StringTypeHandler.getResult(StringTypeHandler.java:48) - 使用自定义类型,结果获取列名字符串
2019-04-13 05:03:33.640 [DEBUG] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:143) - <==      Total: 1
2019-04-13 05:03:33.640 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.resetAutoCommit(JdbcTransaction.java:122) - Resetting autocommit to true on JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@bc84129]
2019-04-13 05:03:33.676 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.close(JdbcTransaction.java:90) - Closing JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@bc84129]
2019-04-13 05:03:33.677 [DEBUG] org.apache.ibatis.datasource.pooled.PooledDataSource.pushConnection(PooledDataSource.java:362) - Returned connection 197673257 to pool.
2019-04-13 05:03:33.677 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.openConnection(JdbcTransaction.java:136) - Opening JDBC Connection
2019-04-13 05:03:33.677 [DEBUG] org.apache.ibatis.datasource.pooled.PooledDataSource.popConnection(PooledDataSource.java:397) - Checked out connection 197673257 from pool.
2019-04-13 05:03:33.677 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.setDesiredAutoCommit(JdbcTransaction.java:100) - Setting autocommit to false on JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@bc84129]
2019-04-13 05:03:33.711 [DEBUG] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:143) - ==>  Preparing: SELECT id, role_name, note FROM t_role4 WHERE id = ? 
2019-04-13 05:03:33.712 [DEBUG] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:143) - ==> Parameters: 100(Integer)
2019-04-13 05:03:33.747 [INFO ] com.ming.MyBatis.StringTypeHandler.getResult(StringTypeHandler.java:48) - 使用自定义类型,结果获取列名字符串
2019-04-13 05:03:33.748 [INFO ] com.ming.MyBatis.StringTypeHandler.getResult(StringTypeHandler.java:48) - 使用自定义类型,结果获取列名字符串
2019-04-13 05:03:33.748 [DEBUG] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:143) - <==      Total: 1
2019-04-13 05:03:33.749 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.resetAutoCommit(JdbcTransaction.java:122) - Resetting autocommit to true on JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@bc84129]
2019-04-13 05:03:33.780 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.close(JdbcTransaction.java:90) - Closing JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@bc84129]
2019-04-13 05:03:33.780 [DEBUG] org.apache.ibatis.datasource.pooled.PooledDataSource.pushConnection(PooledDataSource.java:362) - Returned connection 197673257 to pool.
2019-04-13 05:03:33.781 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.openConnection(JdbcTransaction.java:136) - Opening JDBC Connection
2019-04-13 05:03:33.781 [DEBUG] org.apache.ibatis.datasource.pooled.PooledDataSource.popConnection(PooledDataSource.java:397) - Checked out connection 197673257 from pool.
2019-04-13 05:03:33.781 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.setDesiredAutoCommit(JdbcTransaction.java:100) - Setting autocommit to false on JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@bc84129]
2019-04-13 05:03:33.830 [DEBUG] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:143) - ==>  Preparing: SELECT id, role_name, note FROM t_role4 WHERE id = ? 
2019-04-13 05:03:33.831 [DEBUG] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:143) - ==> Parameters: 100(Integer)
2019-04-13 05:03:33.868 [INFO ] com.ming.MyBatis.StringTypeHandler.getResult(StringTypeHandler.java:48) - 使用自定义类型,结果获取列名字符串
2019-04-13 05:03:33.870 [INFO ] com.ming.MyBatis.StringTypeHandler.getResult(StringTypeHandler.java:48) - 使用自定义类型,结果获取列名字符串
2019-04-13 05:03:33.870 [DEBUG] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:143) - <==      Total: 1
2019-04-13 05:03:33.872 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.resetAutoCommit(JdbcTransaction.java:122) - Resetting autocommit to true on JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@bc84129]
2019-04-13 05:03:33.913 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.close(JdbcTransaction.java:90) - Closing JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@bc84129]
2019-04-13 05:03:33.914 [DEBUG] org.apache.ibatis.datasource.pooled.PooledDataSource.pushConnection(PooledDataSource.java:362) - Returned connection 197673257 to pool.
2019-04-13 05:03:33.914 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.openConnection(JdbcTransaction.java:136) - Opening JDBC Connection
2019-04-13 05:03:33.915 [DEBUG] org.apache.ibatis.datasource.pooled.PooledDataSource.popConnection(PooledDataSource.java:397) - Checked out connection 197673257 from pool.
2019-04-13 05:03:33.915 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.setDesiredAutoCommit(JdbcTransaction.java:100) - Setting autocommit to false on JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@bc84129]
2019-04-13 05:03:33.956 [DEBUG] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:143) - ==>  Preparing: SELECT id, role_name, note FROM t_role4 WHERE id = ? 
2019-04-13 05:03:33.957 [DEBUG] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:143) - ==> Parameters: 100(Integer)
2019-04-13 05:03:33.994 [INFO ] com.ming.MyBatis.StringTypeHandler.getResult(StringTypeHandler.java:48) - 使用自定义类型,结果获取列名字符串
2019-04-13 05:03:33.994 [INFO ] com.ming.MyBatis.StringTypeHandler.getResult(StringTypeHandler.java:48) - 使用自定义类型,结果获取列名字符串
2019-04-13 05:03:33.995 [DEBUG] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:143) - <==      Total: 1
2019-04-13 05:03:33.995 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.resetAutoCommit(JdbcTransaction.java:122) - Resetting autocommit to true on JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@bc84129]
2019-04-13 05:03:34.029 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.close(JdbcTransaction.java:90) - Closing JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@bc84129]
2019-04-13 05:03:34.029 [DEBUG] org.apache.ibatis.datasource.pooled.PooledDataSource.pushConnection(PooledDataSource.java:362) - Returned connection 197673257 to pool.
2019-04-13 05:03:34.030 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.openConnection(JdbcTransaction.java:136) - Opening JDBC Connection
2019-04-13 05:03:34.030 [DEBUG] org.apache.ibatis.datasource.pooled.PooledDataSource.popConnection(PooledDataSource.java:397) - Checked out connection 197673257 from pool.
2019-04-13 05:03:34.030 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.setDesiredAutoCommit(JdbcTransaction.java:100) - Setting autocommit to false on JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@bc84129]
2019-04-13 05:03:34.095 [DEBUG] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:143) - ==>  Preparing: SELECT id, role_name, note FROM t_role4 WHERE id = ? 
2019-04-13 05:03:34.097 [DEBUG] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:143) - ==> Parameters: 100(Integer)
2019-04-13 05:03:34.133 [INFO ] com.ming.MyBatis.StringTypeHandler.getResult(StringTypeHandler.java:48) - 使用自定义类型,结果获取列名字符串
2019-04-13 05:03:34.133 [INFO ] com.ming.MyBatis.StringTypeHandler.getResult(StringTypeHandler.java:48) - 使用自定义类型,结果获取列名字符串
2019-04-13 05:03:34.134 [DEBUG] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:143) - <==      Total: 1
2019-04-13 05:03:34.134 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.resetAutoCommit(JdbcTransaction.java:122) - Resetting autocommit to true on JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@bc84129]
2019-04-13 05:03:34.168 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.close(JdbcTransaction.java:90) - Closing JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@bc84129]
2019-04-13 05:03:34.169 [DEBUG] org.apache.ibatis.datasource.pooled.PooledDataSource.pushConnection(PooledDataSource.java:362) - Returned connection 197673257 to pool.
2019-04-13 05:03:34.170 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.openConnection(JdbcTransaction.java:136) - Opening JDBC Connection
2019-04-13 05:03:34.170 [DEBUG] org.apache.ibatis.datasource.pooled.PooledDataSource.popConnection(PooledDataSource.java:397) - Checked out connection 197673257 from pool.
2019-04-13 05:03:34.171 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.setDesiredAutoCommit(JdbcTransaction.java:100) - Setting autocommit to false on JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@bc84129]
2019-04-13 05:03:34.214 [DEBUG] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:143) - ==>  Preparing: SELECT id, role_name, note FROM t_role4 WHERE id = ? 
2019-04-13 05:03:34.215 [DEBUG] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:143) - ==> Parameters: 100(Integer)
2019-04-13 05:03:34.252 [INFO ] com.ming.MyBatis.StringTypeHandler.getResult(StringTypeHandler.java:48) - 使用自定义类型,结果获取列名字符串
2019-04-13 05:03:34.252 [INFO ] com.ming.MyBatis.StringTypeHandler.getResult(StringTypeHandler.java:48) - 使用自定义类型,结果获取列名字符串
2019-04-13 05:03:34.253 [DEBUG] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:143) - <==      Total: 1
2019-04-13 05:03:34.254 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.resetAutoCommit(JdbcTransaction.java:122) - Resetting autocommit to true on JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@bc84129]
2019-04-13 05:03:34.291 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.close(JdbcTransaction.java:90) - Closing JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@bc84129]
2019-04-13 05:03:34.291 [DEBUG] org.apache.ibatis.datasource.pooled.PooledDataSource.pushConnection(PooledDataSource.java:362) - Returned connection 197673257 to pool.
2019-04-13 05:03:34.292 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.openConnection(JdbcTransaction.java:136) - Opening JDBC Connection
2019-04-13 05:03:34.292 [DEBUG] org.apache.ibatis.datasource.pooled.PooledDataSource.popConnection(PooledDataSource.java:397) - Checked out connection 197673257 from pool.
2019-04-13 05:03:34.292 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.setDesiredAutoCommit(JdbcTransaction.java:100) - Setting autocommit to false on JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@bc84129]
2019-04-13 05:03:34.336 [DEBUG] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:143) - ==>  Preparing: SELECT id, role_name, note FROM t_role4 WHERE id = ? 
2019-04-13 05:03:34.337 [DEBUG] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:143) - ==> Parameters: 100(Integer)
2019-04-13 05:03:34.379 [INFO ] com.ming.MyBatis.StringTypeHandler.getResult(StringTypeHandler.java:48) - 使用自定义类型,结果获取列名字符串
2019-04-13 05:03:34.380 [INFO ] com.ming.MyBatis.StringTypeHandler.getResult(StringTypeHandler.java:48) - 使用自定义类型,结果获取列名字符串
2019-04-13 05:03:34.380 [DEBUG] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:143) - <==      Total: 1
2019-04-13 05:03:34.381 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.resetAutoCommit(JdbcTransaction.java:122) - Resetting autocommit to true on JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@bc84129]
2019-04-13 05:03:34.415 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.close(JdbcTransaction.java:90) - Closing JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@bc84129]
2019-04-13 05:03:34.415 [DEBUG] org.apache.ibatis.datasource.pooled.PooledDataSource.pushConnection(PooledDataSource.java:362) - Returned connection 197673257 to pool.

ps 类型转换的问题

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 212,185评论 6 493
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 90,445评论 3 385
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 157,684评论 0 348
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 56,564评论 1 284
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 65,681评论 6 386
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 49,874评论 1 290
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,025评论 3 408
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 37,761评论 0 268
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,217评论 1 303
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 36,545评论 2 327
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,694评论 1 341
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,351评论 4 332
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,988评论 3 315
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,778评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,007评论 1 266
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 46,427评论 2 360
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 43,580评论 2 349

推荐阅读更多精彩内容