use of org.dbflute.jdbc.ValueType in project dbflute-core by dbflute.
the class TnRelationRowCreatorExtension method registerRelationValue.
protected void registerRelationValue(TnRelationRowCreationResource res, String columnName) throws SQLException {
final TnPropertyMapping mapping = res.getCurrentPropertyMapping();
Object value = null;
if (res.containsRelationKeyColumn(columnName)) {
// #RELKEY
// if this column is relation key, it gets the value from relation key values
// for performance and avoiding twice getting same column value
value = res.extractRelationKeyValue(columnName);
} else {
final ValueType valueType = mapping.getValueType();
final Map<String, Map<String, Integer>> selectIndexMap = res.getSelectIndexMap();
final ResultSet rs = res.getResultSet();
if (selectIndexMap != null) {
final String relationNoSuffix = res.getRelationNoSuffix();
value = ResourceContext.getRelationValue(rs, relationNoSuffix, columnName, valueType, selectIndexMap);
} else {
value = valueType.getValue(rs, columnName);
}
}
handleRelationValueRegistration(res, mapping, value);
}
use of org.dbflute.jdbc.ValueType in project dbflute-core by dbflute.
the class TnProcedureMetaDataFactory method findValueType.
// ===================================================================================
// Value Type
// ==========
protected ValueType findValueType(DfPropertyDesc parameterDesc) {
final Class<?> pmbType = parameterDesc.getBeanDesc().getBeanClass();
final String paramName = parameterDesc.getPropertyName();
final Class<?> paramType = parameterDesc.getPropertyType();
final Object valueTypeDef = _annotationReader.getValueType(parameterDesc);
if (valueTypeDef instanceof ValueType) {
return (ValueType) valueTypeDef;
} else {
final String keyName = (valueTypeDef != null ? valueTypeDef.toString() : null);
final DBDef dbdef = ResourceContext.currentDBDef();
return _valueTypeProvider.provide(pmbType, paramName, paramType, keyName, dbdef);
}
}
use of org.dbflute.jdbc.ValueType in project dbflute-core by dbflute.
the class DfLReverseDataExtractor method createColumnValueTypeMap.
protected Map<String, ValueType> createColumnValueTypeMap(List<Column> columnList) {
final Map<String, ValueType> valueTypeMap = new LinkedHashMap<String, ValueType>();
for (Column column : columnList) {
final String columnName = column.getName();
// create value type for the column
final ValueType valueType;
if (column.isJavaNativeStringObject()) {
if (column.isDbTypeStringClob()) {
valueType = new StringClobType();
} else {
valueType = new StringType();
}
} else if (column.isJavaNativeDateObject()) {
// date types should be treated correctly
if (column.isJdbcTypeTime()) {
valueType = new TimeType();
} else if (column.isJdbcTypeTimestamp()) {
valueType = new TimestampType();
} else if (column.isJdbcTypeDate()) {
if (column.isDbTypeOracleDate()) {
valueType = new UtilDateAsTimestampType();
} else {
valueType = new UtilDateAsSqlDateType();
}
} else {
// no way
valueType = new TimestampType();
}
} else if (column.isJavaNativeBinaryObject()) {
// unsupported BLOG as load data
valueType = new NullBytesType();
} else {
// other types are treated as string
// because ReplaceSchema can accept them
valueType = new StringType();
}
valueTypeMap.put(columnName, valueType);
}
return valueTypeMap;
}
use of org.dbflute.jdbc.ValueType in project dbflute-core by dbflute.
the class DfLReverseDataExtractor method processLargeData.
// ===================================================================================
// Large Data
// ==========
protected DfLReverseDataResult processLargeData(Table table, final List<String> sqlList) {
final DfJdbcFacade facade = createJdbcFacade();
final Map<String, ValueType> valueTypeMap = createColumnValueTypeMap(table.getColumnList());
final DfJFadStringConverter converter = createStringConverter();
final DfJFadCursorCallback callback = facade.selectCursor(sqlList, valueTypeMap, converter);
return new DfLReverseDataResult(callback);
}
use of org.dbflute.jdbc.ValueType in project dbflute-core by dbflute.
the class TnValueTypesTest method test_getValueType_byJdbcType_dynamicObject_threadSafe_basic.
public void test_getValueType_byJdbcType_dynamicObject_threadSafe_basic() throws Exception {
// ## Arrange ##
ExecutionCreator<ValueType> creator = new ExecutionCreator<ValueType>() {
public Execution<ValueType> create() {
return new Execution<ValueType>() {
int _index = 12345678;
public ValueType execute() {
if (Thread.currentThread().getId() % 2 == 0) {
++_index;
}
final int sqlType = _index;
log(sqlType);
final ValueType valueType = TnValueTypes.getValueType(sqlType);
assertEquals(sqlType, valueType.getSqlType());
assertTrue(TnValueTypes.isDynamicObject(valueType));
return valueType;
}
};
}
};
// ## Act & Assert ##
fireSameExecution(creator);
}
Aggregations