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

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

  •  01-07-2022
  •  | 
  •  

Pregunta

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?

¿Fue útil?

Solución 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.

Otros consejos

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

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top