What is the MyBatis equivalent to the Ibatis update(String, Object, int) method?

StackOverflow https://stackoverflow.com/questions/19588253

  •  01-07-2022
  •  | 
  •  

There is an update method in iBatis SqlMapClientTemplate that allows to specify how many rows are expected to be updated (and throws exception if this is not matched).

Is there any equivalent to this method in MyBatis' sqlSession? Those docs suggest there isn't.

What is the best way to implement such a check the other way?

有帮助吗?

解决方案 2

Just came back to that question and realized that it was really trivial.

Source code of iBatis' overloaded update just calls the regular update(String, Object) and checks returned value.

As myBatis also has update(String, Object), this can be simply implemented the same way. Simplicity of this method was probably the reason to drop its support in myBatis.

其他提示

There's no such equivalent method in mybatis' spring extension

http://mybatis.github.io/spring/apidocs/reference/org/mybatis/spring/SqlSessionTemplate.html

Maybe you can raise it as an issue or submit as a pull request to the team :P

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top