Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support global configuration for applying sql provider type when omit on annotation #1951

Merged

Conversation

kazuki43zoo
Copy link
Member

@kazuki43zoo kazuki43zoo commented Jun 6, 2020

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.

@kazuki43zoo kazuki43zoo added the enhancement Improve a feature or add a new feature label Jun 7, 2020
@kazuki43zoo kazuki43zoo added this to the 3.5.6 milestone Jun 7, 2020
@kazuki43zoo kazuki43zoo self-assigned this Jun 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improve a feature or add a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant