private JDBCTypeSimple createTypeSimple(JDBCCMPFieldMetaData cmpField) {
String columnName = cmpField.getColumnName();
Class javaType = cmpField.getFieldType();
JDBCMappingMetaData typeMappingMD = typeMapping.getTypeMappingMetaData(javaType);
String paramSetter = typeMappingMD.getParamSetter();
String resultReader = typeMappingMD.getResultReader();
int jdbcType;
String sqlType = cmpField.getSQLType();
if (sqlType != null) {
jdbcType = cmpField.getJDBCType();
} else {
// get jdbcType and sqlType from typeMapping
sqlType = typeMappingMD.getSqlType();
jdbcType = typeMappingMD.getJdbcType();
}
boolean notNull = cmpField.isNotNull();
boolean autoIncrement = cmpField.isAutoIncrement();
Mapper mapper = null;
JDBCUserTypeMappingMetaData userTypeMapping = (JDBCUserTypeMappingMetaData) userTypeMappings.get(javaType.getName());
if (userTypeMapping != null) {
String mappedTypeStr = userTypeMapping.getMappedType();
try {
final ClassLoader contextClassLoader = TCLAction.UTIL.getContextClassLoader();
Class mapperClass = contextClassLoader.loadClass(userTypeMapping.getMapper());
mapper = (Mapper) mapperClass.newInstance();
javaType = contextClassLoader.loadClass(mappedTypeStr);
if (cmpField.getSQLType() == null) {
JDBCMappingMetaData mappingMD = typeMapping.getTypeMappingMetaData(javaType);
sqlType = mappingMD.getSqlType();
jdbcType = mappingMD.getJdbcType();
paramSetter = mappingMD.getParamSetter();
resultReader = mappingMD.getResultReader();
}
} catch (ClassNotFoundException e) {
throw new RuntimeException("Class not found for mapper: " + userTypeMapping.getMapper(), e);
} catch (Exception e) {
throw new RuntimeException("Could not instantiate mapper: " + userTypeMapping.getMapper(), e);