因为之前使用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太容易了。

相关文章:

  • 2021-12-08
  • 2021-11-28
  • 2021-12-29
  • 2021-10-29
  • 2021-11-29
  • 2021-11-01
  • 2021-09-29
  • 2021-10-17
猜你喜欢
  • 2021-09-12
  • 2021-06-14
  • 2021-08-15
  • 2021-11-11
  • 2021-12-02
  • 2022-01-15
  • 2021-09-10
  • 2021-10-03
相关资源
相似解决方案