I propose to support a global configuration for applying sql provider type when omit type attribute on sql provider annotation(such as @SelectProvider, etc). We has been supported the mechanism that use a shared sql provider class on all mapper methods, however developer need to specify explicitly the type on all mapper methods as follow:

mapper methods (on current version):

public interface MyMapper {
  @SelectProvider(SharedSqlProvider.class)
  String select(int id);
  @InsertProvider(SharedSqlProvider.class)
  void insert(String name);
  @UpdateProvider(SharedSqlProvider.class)
  void update(int id, String name);
  @DeleteProvider(SharedSqlProvider.class)
  void delete(int id);
}

There is case that I feel it's redundant. As this changes, developer can be omit the type attribute on all mapper methods as follow:

mapper methods:

public interface MyMapper {
  @SelectProvider
  String select(int id);
  @InsertProvider
  void insert(String name);
  @UpdateProvider
  void update(int id, String name);
  @DeleteProvider
  void delete(int id);
}

global configuration:

Configuration configuration = new Configuration();
configuration.setDefaultSqlProviderType(SharedSqlProvider.class);
// ...

Note

The mybatis-thymeleaf and mybaits-freemarker provids the sql provider class(TemplateFilePathProvider) that can be use on all mapper methods. I want to use this mechanism when use these class.

  • https://mybatis.org/thymeleaf-scripting/user-guide.html#_templatefilepathprovider
  • http://mybatis.org/freemarker-scripting/#TemplateFilePathProvider