use of org.qi4j.index.sql.support.api.SQLTypeInfo in project qi4j-sdk by Qi4j.
the class AbstractSQLStartup method initTypes.
private void initTypes() {
DataTypeFactory dt = this._vendor.getDataTypeFactory();
this._primitiveTypes = new HashMap<>();
this._primitiveTypes.put(Boolean.class, dt.sqlBoolean());
this._primitiveTypes.put(Byte.class, dt.smallInt());
this._primitiveTypes.put(Short.class, dt.smallInt());
this._primitiveTypes.put(Integer.class, dt.integer());
this._primitiveTypes.put(Long.class, dt.bigInt());
this._primitiveTypes.put(Float.class, dt.real());
this._primitiveTypes.put(Double.class, dt.doublePrecision());
this._primitiveTypes.put(Date.class, dt.timeStamp(true));
this._primitiveTypes.put(Character.class, dt.integer());
this._primitiveTypes.put(String.class, dt.sqlVarChar(5000));
this._primitiveTypes.put(BigInteger.class, dt.decimal());
this._primitiveTypes.put(BigDecimal.class, dt.decimal());
Map<Class<?>, Integer> jdbcTypes = new HashMap<>();
jdbcTypes.put(Boolean.class, Types.BOOLEAN);
jdbcTypes.put(Byte.class, Types.SMALLINT);
jdbcTypes.put(Short.class, Types.SMALLINT);
jdbcTypes.put(Integer.class, Types.INTEGER);
jdbcTypes.put(Long.class, Types.BIGINT);
jdbcTypes.put(Float.class, Types.REAL);
jdbcTypes.put(Double.class, Types.DOUBLE);
jdbcTypes.put(Date.class, Types.TIMESTAMP);
jdbcTypes.put(Character.class, Types.INTEGER);
jdbcTypes.put(String.class, Types.VARCHAR);
jdbcTypes.put(BigInteger.class, Types.NUMERIC);
jdbcTypes.put(BigDecimal.class, Types.NUMERIC);
this._state.javaTypes2SQLTypes().set(jdbcTypes);
this._customizableTypes = new HashMap<>();
//
this._customizableTypes.put(//
String.class, new SQLTypeCustomizer() {
@Override
public SQLDataType customizeType(Type propertyType, SQLTypeInfo sqlTypeInfo) {
return _vendor.getDataTypeFactory().sqlVarChar(sqlTypeInfo.maxLength());
}
});
//
this._customizableTypes.put(//
BigInteger.class, new SQLTypeCustomizer() {
@Override
public SQLDataType customizeType(Type propertyType, SQLTypeInfo sqlTypeInfo) {
return _vendor.getDataTypeFactory().decimal(sqlTypeInfo.maxLength());
}
});
//
this._customizableTypes.put(//
BigDecimal.class, new SQLTypeCustomizer() {
@Override
public SQLDataType customizeType(Type propertyType, SQLTypeInfo sqlTypeInfo) {
return _vendor.getDataTypeFactory().decimal(sqlTypeInfo.maxLength());
}
});
}
Aggregations