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