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

MapToFactory: reuse a single ResultReturner #2436

Merged
merged 1 commit into from
Jul 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public SqlStatementParameterCustomizer createForParameter(Annotation annotation,
Parameter param,
int index,
Type type) {
ResultReturner returner = ResultReturner.forMethod(sqlObjectType, method);
return (sqlStatement, arg) -> {
final QualifiedType<?> mapTo;

Expand All @@ -45,7 +46,6 @@ public SqlStatementParameterCustomizer createForParameter(Annotation annotation,
throw new UnsupportedOperationException("@MapTo must take a GenericType, QualifiedType, or Type, but got a " + arg.getClass().getName());
}

ResultReturner returner = ResultReturner.forMethod(sqlObjectType, method);
sqlStatement.getConfig(SqlObjectStatementConfiguration.class).setReturner(
() -> returner.mappedResult(((ResultBearing) sqlStatement).mapTo(mapTo), sqlStatement.getContext()));
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
/**
* Helper class used by the {@link CustomizingStatementHandler}s to assemble
* the result Collection, Iterable, etc.
* The instance may be reused and should be stateless.
*/
abstract class ResultReturner {

Expand Down