public Class getJavaType()

in empire-db-codegen/src/main/java/org/apache/empire/db/codegen/WriterService.java [229:274]


	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 AUTOINC:
		case INTEGER:
			return Long.class;
        case VARCHAR:
			return String.class;
		case DATE:
		case DATETIME:
        case TIMESTAMP:
			return Date.class;
		case CHAR:
			return String.class;
		case FLOAT:
			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;
		}
	}