How to remove `@ConstructorArgs` ?
pondered opened this issue · 4 comments
In MyBatis, the result mapping must match the query. You can remove the constructor arg here if, and only if, you're not using this mapper in other places.
We supply a generic mapper that can be used for any query - org.mybatis.dynamic.sql.util.mybatis3.CommonSelectMapper. The selectOneInteger method in that mapper would work well in this situation.
oh ,thanks ,but i see mapper not extends CommonSelectMapper, why?
MyBatis Generator does not generate mappers that extend the CommonSelectMapper because the generator builds result maps that match the table rows.
You can can make the change to have your mapper extend CommonSelectMapper along with the other common mappers, or you could just add the CommonSelectMapper standalone to your configuration, or you could write a generator plugin to add this extension to every mapper or a subset of mappers. Whatever makes the most sense in your usage model will work. If it were me, I would just add the CommonSelectMapper to your configuration one time.
Thank you very much

