*/\r
boolean create() default true;\r
\r
- /**\r
- * Whether only supported types are mapped. If true, unsupported mapped\r
- * types will throw an IciqlException. If false, unsupported mapped\r
- * types will default to VARCHAR. Default: true.\r
- */\r
- boolean strictTypeMapping() default true;\r
-\r
/**\r
* If true, only fields that are explicitly annotated as IQColumn are\r
* mapped. Default: true.\r
*
* @param fieldDef
* the field to map
- * @param strictTypeMapping
- * throws a IciqlException if type is unsupported
* @return
*/
- static String getDataType(FieldDefinition fieldDef, boolean strictTypeMapping) {
+ static String getDataType(FieldDefinition fieldDef) {
Class<?> fieldClass = fieldDef.field.getType();
if (fieldClass.isEnum()) {
switch (fieldDef.enumType) {
if (SUPPORTED_TYPES.containsKey(fieldClass)) {
return SUPPORTED_TYPES.get(fieldClass);
}
- if (!strictTypeMapping) {
- return "VARCHAR";
- }
throw new IciqlException("Unsupported type " + fieldClass.getName());
}
void mapFields() {\r
boolean byAnnotationsOnly = false;\r
boolean inheritColumns = false;\r
- boolean strictTypeMapping = false;\r
if (clazz.isAnnotationPresent(IQTable.class)) {\r
IQTable tableAnnotation = clazz.getAnnotation(IQTable.class);\r
byAnnotationsOnly = tableAnnotation.annotationsOnly();\r
inheritColumns = tableAnnotation.inheritColumns();\r
- strictTypeMapping = tableAnnotation.strictTypeMapping();\r
}\r
\r
List<Field> classFields = Utils.newArrayList();\r
fieldDef.nullable = nullable;\r
fieldDef.defaultValue = defaultValue;\r
fieldDef.enumType = enumType;\r
- fieldDef.dataType = ModelUtils.getDataType(fieldDef, strictTypeMapping);\r
+ fieldDef.dataType = ModelUtils.getDataType(fieldDef);\r
fields.add(fieldDef);\r
}\r
}\r
/**
* A data class that contains a column for each data type.
*/
-@IQTable(strictTypeMapping = true)
+@IQTable
@IQIndexes({ @IQIndex({ "myLong", "myInteger" }), @IQIndex(type = IndexType.HASH, value = "myString") })
@IQVersion(1)
public class SupportedTypes {
/**
* This class demonstrates the table upgrade.
*/
- @IQTable(name = "SupportedTypes", inheritColumns = true, strictTypeMapping = true)
+ @IQTable(name = "SupportedTypes", inheritColumns = true)
@IQVersion(2)
public static class SupportedTypes2 extends SupportedTypes {