[#4597] Log warning when <forcedType/> doesn't have any matching SQLDataType or <customType/>

This commit is contained in:
lukaseder 2015-10-07 11:49:38 +02:00
parent 5454fdbd0d
commit 2b2dcf5aa8

View File

@ -44,12 +44,15 @@ package org.jooq.util;
import static org.jooq.tools.Convert.convert;
import static org.jooq.tools.StringUtils.isEmpty;
import java.io.StringWriter;
import java.sql.Types;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.xml.bind.JAXB;
import org.jooq.DataType;
import org.jooq.exception.SQLDialectNotSupportedException;
import org.jooq.impl.DateAsTimestampBinding;
@ -189,13 +192,22 @@ abstract class AbstractTypedElementDefinition<T extends Definition>
}
// Other forced types are UDT's, enums, etc.
else {
else if (customType != null) {
l = result.getLength();
p = result.getPrecision();
s = result.getScale();
String t = result.getType();
result = new DefaultDataTypeDefinition(db, child.getSchema(), t, l, p, s, n, d, type, converter, binding);
}
// [#4597] If we don't have a type-rewrite (forcedDataType) or a
// matching customType, the user probably malconfigured
// their <forcedTypes/> or <customTypes/>
else {
StringWriter writer = new StringWriter();
JAXB.marshal(forcedType, writer);
log.warn("Bad configuration for <forcedType/> " + forcedType.getName() + ". No matching <customType/> found, and no matching SQLDataType found: " + writer);
}
}
return result;