Improve error message throw on DTO unmapped DB column

This commit is contained in:
rob bygrave
2020-05-27 21:39:16 +12:00
parent f6f9511d2a
commit ffaf00c064
@@ -88,7 +88,7 @@ class DtoMeta {
if (request.isRelaxedMode()) {
property = DtoReadSetColumnSkip.INSTANCE;
} else {
throw new IllegalStateException("Unable to map DB column " + cols[i] + " to a property with a setter method on " + dtoType);
throw new IllegalStateException(unableToMapColumnMessage(cols[i]));
}
}
setterProps[pos++] = property;
@@ -97,6 +97,10 @@ class DtoMeta {
return new DtoQueryPlanConPlus(request, maxArgConstructor, setterProps);
}
private String unableToMapColumnMessage(DtoColumn col) {
return "Unable to map DB column " + col + " to a property with a setter method on " + dtoType+". Consider query.setRelaxedMode() to skip mapping this column.";
}
private DtoQueryPlan matchSetters(DtoMappingRequest request) {
DtoColumn[] cols = request.getColumnMeta();
@@ -110,7 +114,7 @@ class DtoMeta {
if (request.isRelaxedMode()) {
property = DtoReadSetColumnSkip.INSTANCE;
} else {
throw new IllegalStateException("Unable to map DB column " + cols[i] + " to a property with a setter method on " + dtoType);
throw new IllegalStateException(unableToMapColumnMessage(cols[i]));
}
}
setterProps[i] = property;