《深入浅出MyBatis技术原理与实战》修复错误和歧义

《深入浅出MyBatis技术原理与实战》的一些错误修复,欢迎大家跟帖指出:


1、出版社编辑错误

p25-26页:“role_no_1” ---->1L    这些是出版社编辑错误,方法修改为selectOne("getRole", 1L)


2、p60页: 3.4.3.2节关于EnumTypeHandler操作表述不清。

(1)测试前应该是把数据库表t_role的字段sex从之前的整数型修改为VARCHAR型。

(2)p61页的EnumOrdinalTypeHandler修改为EnumTypeHandler

EnumTypeHandler是根据字符串去变换枚举和数据库字段的。


3、最新MyBatis版本插件接口变动

使用MyBatis 3.4.1或者其以上版本的,由于StatementHandler接口定义的变化,prepare方法的定义为:

Statement prepare(Connection connection, Integer transactionTimeout)  throws SQLException;

而编写书时,书中的版本为3.3.0,当时接口的定义为

Statement prepare(Connection connection)  throws SQLException;

所以插件的拦截签名需要根据你的版本修改。

使用MyBatis 3.4.1或者其以上版本

@Intercepts({ 

@Signature(type = StatementHandler.class
method = "prepare"
args = {Connection.class, Integer.class})})


使用MyBatis 3.4.1(不包含)以下

@Intercepts({ 

@Signature(type = StatementHandler.class
method = "prepare"
args = {Connection.class})})








猜你喜欢

转载自blog.csdn.net/ykzhen2015/article/details/52464085