use of org.dbflute.jdbc.Classification in project dbflute-core by dbflute.
the class FunCustodial method throwUndefinedClassificationCodeException.
protected static void throwUndefinedClassificationCodeException(String tableDbName, String columnDbName, ClassificationMeta meta, Object code) {
final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
br.addNotice("Undefined classification code was set to the entity.");
br.addItem("Advice");
br.addElement("Confirm the value of the classification column on your database,");
br.addElement("or setting value to your entity.");
br.addElement("The code is NOT one of classification code defined on DBFlute.");
br.addElement("");
br.addElement("_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/");
br.addElement(" Use formal code!");
br.addElement(" Or add the code to classification definition.");
br.addElement("_/_/_/_/_/_/_/_/_/_/");
br.addElement("");
br.addElement("Or if you (reluctantly) need to allow it, change the option like this:");
br.addElement("but *Deprecated");
br.addElement("(classificationDefinitionMap.dfprop)");
br.addElement(" ; [classification-name] = list:{");
br.addElement(" ; map:{");
br.addElement(" ; topComment=...; codeType=...");
br.addElement(" ; undefinedHandlingType=ALLOWED");
br.addElement(" }");
br.addElement(" map:{...}");
br.addElement(" }");
br.addElement("*for your information, the default of undefinedHandlingType is LOGGING");
br.addItem("Table");
br.addElement(tableDbName);
br.addItem("Column");
br.addElement(columnDbName);
br.addItem("Classification");
br.addElement(meta.classificationName());
final List<Classification> listAll = meta.listAll();
final StringBuilder sb = new StringBuilder();
for (Classification cls : listAll) {
if (sb.length() > 0) {
sb.append(", ");
}
sb.append(cls.name()).append("(").append(cls.code()).append(")");
}
br.addElement(sb.toString());
br.addItem("Undefined Code");
br.addElement(code);
final String msg = br.buildExceptionMessage();
throw new UndefinedClassificationCodeException(msg);
}
use of org.dbflute.jdbc.Classification in project dbflute-core by dbflute.
the class ClassificationType method bindValue.
public void bindValue(Connection conn, PreparedStatement ps, int index, Object value) throws SQLException {
if (value == null) {
setNull(ps, index);
} else {
if (!(value instanceof Classification)) {
String msg = "The value should be classification:";
msg = msg + " value=" + value + " type=" + value.getClass();
throw new IllegalStateException(msg);
}
final Classification cls = (Classification) value;
if (ClassificationCodeType.String.equals(cls.meta().codeType())) {
ps.setString(index, cls.code());
} else if (ClassificationCodeType.Number.equals(cls.meta().codeType())) {
ps.setInt(index, DfTypeUtil.toInteger(cls.code()));
} else if (ClassificationCodeType.Boolean.equals(cls.meta().codeType())) {
ps.setBoolean(index, DfTypeUtil.toBoolean(cls.code()));
} else {
ps.setObject(index, cls.code());
}
}
}
Aggregations