Fix JdbcMapper blob/clob warning messages and mistaken fallthrough to CLOB case from BLOB

This commit is contained in:
Travis Burtrum 2018-10-09 00:23:22 -04:00
parent fad614f85a
commit 278e99e894
2 changed files with 13 additions and 4 deletions

View File

@ -877,18 +877,24 @@ public class JdbcMapperProcessor extends AbstractProcessor {
"\t\t\t}\n");
return;
} else if (!(types.isAssignable(o, inputStreamType) || types.isAssignable(o, blobType) || types.isAssignable(o, fileType) || types.isAssignable(o, byteArrayType))) {
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "@JdbcMapper.Blob only valid for String, byte[], Blob, InputStream, and File", specialParam.delegate);
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "JdbcMapper {blob:paramName} only valid for String, byte[], Blob, InputStream, and File", specialParam.delegate);
return;
}
// also if we have a blobStringCharset here it's only valid for String so error out
if(specialParam.blobStringCharset != null) {
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "JdbcMapper {blob:charset:paramName} charset can only be specified for String", specialParam.delegate);
}
break;
}
case CLOB: {
if (types.isAssignable(o, stringType)) {
method = "Clob";
variableName = variableName + " == null ? null : new java.io.StringReader(" + variableName + ")";
} else if (!(types.isAssignable(o, readerType) || types.isAssignable(o, clobType))) {
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "@JdbcMapper.Clob only valid for String, Clob, Reader", specialParam.delegate);
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "JdbcMapper {clob:paramName} only valid for String, Clob, Reader", specialParam.delegate);
return;
}
break;
}
}
}

View File

@ -415,7 +415,10 @@ TODO
----
* DOCUMENTATION!!!!!
* sql other than select return boolean, int > 0 ?
* @RunInTransaction void support
* QueryMapper mapping errors should be clearer, especially if a .finish(ResultSet) throws an error
* check QueryMapper/ResultSetMapper closing of ResultSets, it doesn't look guaranteed
* CompilingResultSetMapper fails on inner class like 'public static class Bla {'
* Support Optional<T> for all T instead of null
* change boolean to be consistent with other primitives?
* make sure 'fallback to resultSet.toObject()' never happens at compile-time with JdbcMapper