自定义typehandler
对于自定义typehandler来说,需要在配置文件中注册typehandlers 然后需要实现typehandler接口,
一个例子
首先编写调度的处理类
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
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); } } |
再次编写配置文件
1
2
3
|
<typehandlers> <typehandler jdbctype= "varchar" javatype= "string" handler= "com.ming.mybatis.stringtypehandler" > </typehandlers> |
传入数据库的为的varchar类型,javatype类型为string类型,调度的类为com.ming.mybatis.stringtypehandler
修改映射文件,说明那些需要对结果进行修改
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
<?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中两者类型相同,所以修改如上所示,表类型
书写index.jsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
<%@ 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> |
已经查询成功
查看日志文件,日志文件已经输出相关信息
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
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 类型转换的问题
总结
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,谢谢大家对服务器之家的支持。
原文链接:https://www.iming.info/mybatis-zi-ding-yi-typehandler/