We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
The Jdbc3KeyGenerator and NoKeyGenerator can be share an instance because it hasn't state.
Jdbc3KeyGenerator
NoKeyGenerator
I suggest to share an instance as follow:
e.g) Jdbc3KeyGenerator
public class Jdbc3KeyGenerator implements KeyGenerator { public static final Jdbc3KeyGenerator INSTANCE = new Jdbc3KeyGenerator(); // Add constant // ... }
e.g) MapperAnnotationBuilder
MapperAnnotationBuilder
if (SqlCommandType.INSERT.equals(sqlCommandType) || SqlCommandType.UPDATE.equals(sqlCommandType)) { SelectKey selectKey = method.getAnnotation(SelectKey.class); if (selectKey != null) { keyGenerator = handleSelectKeyAnnotation(selectKey, mappedStatementId, getParameterType(method), languageDriver); keyProperty = selectKey.keyProperty(); } else if (options == null) { keyGenerator = configuration.isUseGeneratedKeys() ? new Jdbc3KeyGenerator() : new NoKeyGenerator(); } else { keyGenerator = options.useGeneratedKeys() ? new Jdbc3KeyGenerator() : new NoKeyGenerator(); keyProperty = options.keyProperty(); keyColumn = options.keyColumn(); } } else { keyGenerator = new NoKeyGenerator(); }
↓
if (SqlCommandType.INSERT.equals(sqlCommandType) || SqlCommandType.UPDATE.equals(sqlCommandType)) { SelectKey selectKey = method.getAnnotation(SelectKey.class); if (selectKey != null) { keyGenerator = handleSelectKeyAnnotation(selectKey, mappedStatementId, getParameterType(method), languageDriver); keyProperty = selectKey.keyProperty(); } else if (options == null) { keyGenerator = configuration.isUseGeneratedKeys() ? Jdbc3KeyGenerator.INSTANCE : NoKeyGenerator.INSTANCE; } else { keyGenerator = options.useGeneratedKeys() ? Jdbc3KeyGenerator.INSTANCE : NoKeyGenerator.INSTANCE; keyProperty = options.keyProperty(); keyColumn = options.keyColumn(); } } else { keyGenerator = NoKeyGenerator.INSTANCE; }
The text was updated successfully, but these errors were encountered:
7232c7e
Improve to share Jdbc3KeyGenerator and NoKeyGenerator instance
f277a00
fix mybatisgh-882
kazuki43zoo
No branches or pull requests
The
Jdbc3KeyGenerator
andNoKeyGenerator
can be share an instance because it hasn't state.I suggest to share an instance as follow:
e.g)
Jdbc3KeyGenerator
e.g)
MapperAnnotationBuilder
↓
The text was updated successfully, but these errors were encountered: