@@ -63,17 +63,15 @@ public ProviderSqlSource(Configuration configuration, Object provider, Class<?>
63
63
providerMethodName = (String ) provider .getClass ().getMethod ("method" ).invoke (provider );
64
64
65
65
for (Method m : this .providerType .getMethods ()) {
66
- if (providerMethodName .equals (m .getName ())) {
67
- if (m .getReturnType () == String .class ) {
68
- if (providerMethod != null ){
69
- throw new BuilderException ("Error creating SqlSource for SqlProvider. Method '"
70
- + providerMethodName + "' is found multiple in SqlProvider '" + this .providerType .getName ()
71
- + "'. Sql provider method can not overload." );
72
- }
73
- this .providerMethod = m ;
74
- this .providerMethodArgumentNames = new ParamNameResolver (configuration , m ).getNames ();
75
- this .providerMethodParameterTypes = m .getParameterTypes ();
66
+ if (providerMethodName .equals (m .getName ()) && CharSequence .class .isAssignableFrom (m .getReturnType ())) {
67
+ if (providerMethod != null ){
68
+ throw new BuilderException ("Error creating SqlSource for SqlProvider. Method '"
69
+ + providerMethodName + "' is found multiple in SqlProvider '" + this .providerType .getName ()
70
+ + "'. Sql provider method can not overload." );
76
71
}
72
+ this .providerMethod = m ;
73
+ this .providerMethodArgumentNames = new ParamNameResolver (configuration , m ).getNames ();
74
+ this .providerMethodParameterTypes = m .getParameterTypes ();
77
75
}
78
76
}
79
77
} catch (BuilderException e ) {
@@ -166,7 +164,8 @@ private String invokeProviderMethod(Object... args) throws Exception {
166
164
if (!Modifier .isStatic (providerMethod .getModifiers ())) {
167
165
targetObject = providerType .newInstance ();
168
166
}
169
- return (String ) providerMethod .invoke (targetObject , args );
167
+ CharSequence sql = (CharSequence ) providerMethod .invoke (targetObject , args );
168
+ return sql != null ? sql .toString () : null ;
170
169
}
171
170
172
171
private String replacePlaceholder (String sql ) {
0 commit comments