因為之前使用mybatis,都是直接使用的mybatis-spring-boot-starter,通過這個starter模塊間接引入的mybatis。目前使用的版本到了2.1.3,其使用的mybatis版本為3.5.5。
切換項目組后,使用了通用mapper,基於tk.mybatis模塊間接依賴的mybatis,其使用的mybatis版本停留在3.4.5。
因為用習慣了高版本的mybatis,降版本到沒太關注變更差異,故而一些使用習慣直接復用了過來。比如update時使用<set />標簽進行,的自動刪除。
針對這個標簽,在3.5.0有一個變更,其與3.4.X版本的語義表達有差異。
3.4.X的代碼如下:
public class SetSqlNode extends TrimSqlNode { private static List<String> suffixList = Arrays.asList(","); public SetSqlNode(Configuration configuration,SqlNode contents) { super(configuration, contents, "SET", null, null, suffixList); } }
其僅處理以,結尾多余的“,”。
3.5.0的代碼如下:
public class SetSqlNode extends TrimSqlNode { private static final List<String> COMMA = Collections.singletonList(","); public SetSqlNode(Configuration configuration,SqlNode contents) { super(configuration, contents, "SET", COMMA, null, COMMA); } }
其允許處理set標簽包裹SQL塊前后多余的",",比之前增加了一個前綴多余的處理。
具體的大版本變化差異:
https://github.com/mybatis/mybatis-3/releases/tag/mybatis-3.5.0
以后使用關鍵包如果跨大版本一定要仔細看看變更記錄,不然出bug太容易了。