*
* @param column the column to get the type for
*/
public Class<?> getJavaType(DBColumn column)
{
DataType type = getDataType(column);
// We added the attribute of original datatype to AUTOINC columns
// in CodeGenParser.addColumn(). Now we need to use it so that
// the g/setters deal with the right Java type.
// If the original data type was not set as an attribute for some
// reason this will just fall through to the bottom and
// return "Byte[]", so no problem.
if (DataType.AUTOINC.equals(type) && null != column.getAttribute("AutoIncDataType"))
{
type = (DataType)column.getAttribute("AutoIncDataType");
}
// TODO might be better to add this to the enum
// TODO use primitives for non-nullable columns?
switch(type){
case INTEGER:
return Long.class;
case TEXT:
return String.class;
case DATE:
return Date.class;
case DATETIME:
return Date.class;
case CHAR:
return String.class;
case DOUBLE:
return Double.class;
case DECIMAL:
return BigDecimal.class;
case BOOL:
return Boolean.class;
case CLOB:
return String.class;
case BLOB:
return Byte[].class;
case UNKNOWN:
return Byte[].class;
default:
log.warn("SQL column type " + type.toString() + " not supported, falling back to byte array.");
return Byte[].class;
}
}