简体   繁体   中英

MyBatis: Getting affected rows number using java interface mapper

Reading MyBatis tutorial I understood that using session in order to execute query is old practice and it's much better to use java interface mapper. I mean that is a good practice :

mapper=session.getMapper(mapperClass);
mapper.updateFoo(boo);

I started using interface mappers and now I need to get the number of affected rows. All examples I've found are with int number=session.update()

My question how to get number of affected rows using mapper?

You can just get the affected rows using java interface mapper in a similar way.

int number = mapper.updateFoo(boo);

And the java interface should be something like follows.

int updateFoo(Foo boo);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM