Generic Support for javaClientGenerator #1373
Open
+130
−5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Implemented generic type support for the
rootInterfaceproperty in MyBatis Generator, addressing issue #1346.Changes Made:
Added utility method in
AbstractJavaClientGenerator:processRootInterfaceWithGenerics(): Processes the rootInterface string and replaces generic placeholders (e.g.,<T>,<T extends Entity>) with the actual record type from the introspected tableisGenericPlaceholder(): Detects if the generic content is a placeholder (single uppercase letter like T, E, K, V, optionally with "extends" or "super" clause)Updated all three Java client generators:
JavaMapperGeneratorSimpleJavaClientGeneratorDynamicSqlMapperGeneratorUpdated documentation:
javaClientGenerator.xhtmlandtable.xhtmldocumentation filesHow It Works:
rootInterface="BaseMapper<T>", it becomesBaseMapper<com.example.User>for a User tablerootInterface="BaseMapper<T extends Entity>", it becomesBaseMapper<com.example.User>rootInterface="BaseMapper"(no generics), it remains unchanged (backward compatible)rootInterface="BaseMapper<com.example.User>"(fully qualified), it's used as-isExample Usage:
This will generate mapper interfaces like:
Resolves
Closes #1346 - Feature Request : Generics support in javaClientGenerator rootInterface
The implementation is backward compatible and passes all linter checks.
Ready for testing and review.
Contribution by Gittensor, learn more at https://gittensor.io/