Search in sources :

Example 1 with SqlBinding

use of com.torodb.backend.converters.sql.SqlBinding in project torodb by torodb.

the class SqlHelper method setPreparedStatementValue.

@SuppressWarnings({ "rawtypes", "unchecked" })
public void setPreparedStatementValue(PreparedStatement preparedStatement, int parameterIndex, FieldType fieldType, KvValue<?> value) throws SQLException {
    DataTypeForKv dataType = dataTypeProvider.getDataType(fieldType);
    KvValueConverter valueConverter = dataType.getKvValueConverter();
    Converter converter = dataType.getConverter();
    SqlBinding sqlBinding = valueConverter.getSqlBinding();
    sqlBinding.set(preparedStatement, parameterIndex, converter.to(value));
}
Also used : DataTypeForKv(com.torodb.backend.converters.jooq.DataTypeForKv) Converter(org.jooq.Converter) KvValueConverter(com.torodb.backend.converters.jooq.KvValueConverter) KvValueConverter(com.torodb.backend.converters.jooq.KvValueConverter) SqlBinding(com.torodb.backend.converters.sql.SqlBinding)

Example 2 with SqlBinding

use of com.torodb.backend.converters.sql.SqlBinding in project torodb by torodb.

the class SqlHelper method setPreparedStatementNullableValue.

@SuppressWarnings({ "rawtypes", "unchecked" })
public void setPreparedStatementNullableValue(PreparedStatement preparedStatement, int parameterIndex, FieldType fieldType, KvValue<?> value) throws SQLException {
    DataTypeForKv dataType = dataTypeProvider.getDataType(fieldType);
    if (value != null) {
        KvValueConverter valueConverter = dataType.getKvValueConverter();
        SqlBinding sqlBinding = valueConverter.getSqlBinding();
        Converter converter = dataType.getConverter();
        sqlBinding.set(preparedStatement, parameterIndex, converter.to(value));
    } else {
        preparedStatement.setNull(parameterIndex, dataType.getSQLType());
    }
}
Also used : DataTypeForKv(com.torodb.backend.converters.jooq.DataTypeForKv) Converter(org.jooq.Converter) KvValueConverter(com.torodb.backend.converters.jooq.KvValueConverter) KvValueConverter(com.torodb.backend.converters.jooq.KvValueConverter) SqlBinding(com.torodb.backend.converters.sql.SqlBinding)

Example 3 with SqlBinding

use of com.torodb.backend.converters.sql.SqlBinding in project torodb by torodb.

the class SqlHelper method getPlaceholder.

@SuppressWarnings({ "rawtypes" })
public String getPlaceholder(FieldType fieldType) {
    DataTypeForKv dataType = dataTypeProvider.getDataType(fieldType);
    KvValueConverter valueConverter = dataType.getKvValueConverter();
    SqlBinding sqlBinding = valueConverter.getSqlBinding();
    return sqlBinding.getPlaceholder();
}
Also used : DataTypeForKv(com.torodb.backend.converters.jooq.DataTypeForKv) KvValueConverter(com.torodb.backend.converters.jooq.KvValueConverter) SqlBinding(com.torodb.backend.converters.sql.SqlBinding)

Example 4 with SqlBinding

use of com.torodb.backend.converters.sql.SqlBinding in project torodb by torodb.

the class SqlHelper method getResultSetValue.

@SuppressWarnings({ "rawtypes" })
public Object getResultSetValue(FieldType fieldType, ResultSet resultSet, int index) throws SQLException {
    DataTypeForKv dataType = dataTypeProvider.getDataType(fieldType);
    KvValueConverter valueConverter = dataType.getKvValueConverter();
    SqlBinding sqlBinding = valueConverter.getSqlBinding();
    return sqlBinding.get(resultSet, index);
}
Also used : DataTypeForKv(com.torodb.backend.converters.jooq.DataTypeForKv) KvValueConverter(com.torodb.backend.converters.jooq.KvValueConverter) SqlBinding(com.torodb.backend.converters.sql.SqlBinding)

Aggregations

DataTypeForKv (com.torodb.backend.converters.jooq.DataTypeForKv)4 KvValueConverter (com.torodb.backend.converters.jooq.KvValueConverter)4 SqlBinding (com.torodb.backend.converters.sql.SqlBinding)4 Converter (org.jooq.Converter)2