public class BasicJdbcConverter extends BasicRelationalConverter implements JdbcConverter
RelationalConverter
that uses a MappingContext
to apply basic conversion of relational values to
property values.
Conversion is configurable by providing a customized CustomConversions
.
MappingContext
,
SimpleTypeHolder
,
CustomConversions
Constructor and Description |
---|
BasicJdbcConverter(MappingContext<? extends RelationalPersistentEntity<?>,? extends RelationalPersistentProperty> context,
RelationResolver relationResolver)
Creates a new
BasicRelationalConverter given MappingContext and a
no-op type factory throwing UnsupportedOperationException on type
creation. |
BasicJdbcConverter(MappingContext<? extends RelationalPersistentEntity<?>,? extends RelationalPersistentProperty> context,
RelationResolver relationResolver,
CustomConversions conversions,
JdbcTypeFactory typeFactory)
Creates a new
BasicRelationalConverter given MappingContext . |
Modifier and Type | Method and Description |
---|---|
Class<?> |
getColumnType(RelationalPersistentProperty property)
The type to be used to store this property in the database.
|
int |
getSqlType(RelationalPersistentProperty property)
The SQL type constant used when using this property as a parameter for a SQL statement.
|
<T> T |
mapRow(PersistentPropertyPathExtension path,
ResultSet resultSet,
Identifier identifier,
Object key)
|
<T> T |
mapRow(RelationalPersistentEntity<T> entity,
ResultSet resultSet,
Object key)
|
Object |
readValue(Object value,
TypeInformation<?> type)
Read a relational value into the desired
destination type . |
JdbcValue |
writeJdbcValue(Object value,
Class<?> columnType,
int sqlType)
Convert a property value into a
JdbcValue that contains the converted value and information how to bind it
to JDBC parameters. |
Object |
writeValue(Object value,
TypeInformation<?> type)
Write a property value into a relational type that can be stored natively.
|
createInstance, getConversions, getConversionService, getMappingContext, getPropertyAccessor
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
createInstance, getConversionService, getMappingContext, getPropertyAccessor
public BasicJdbcConverter(MappingContext<? extends RelationalPersistentEntity<?>,? extends RelationalPersistentProperty> context, RelationResolver relationResolver)
BasicRelationalConverter
given MappingContext
and a
no-op type factory
throwing UnsupportedOperationException
on type
creation. Use BasicJdbcConverter(MappingContext, RelationResolver, CustomConversions, JdbcTypeFactory)
(MappingContext, RelationResolver, JdbcTypeFactory)} to convert arrays and large objects into JDBC-specific types.context
- must not be null.relationResolver
- used to fetch additional relations from the database. Must not be null.public BasicJdbcConverter(MappingContext<? extends RelationalPersistentEntity<?>,? extends RelationalPersistentProperty> context, RelationResolver relationResolver, CustomConversions conversions, JdbcTypeFactory typeFactory)
BasicRelationalConverter
given MappingContext
.context
- must not be null.relationResolver
- used to fetch additional relations from the database. Must not be null.typeFactory
- must not be nullpublic int getSqlType(RelationalPersistentProperty property)
JdbcConverter
getSqlType
in interface JdbcConverter
null
.Types
public Class<?> getColumnType(RelationalPersistentProperty property)
JdbcConverter
String[][]
returns String[]
).getColumnType
in interface JdbcConverter
Class
that is suitable for usage with JDBC drivers.JdbcUtil.sqlTypeFor(Class)
@Nullable public Object readValue(@Nullable Object value, TypeInformation<?> type)
RelationalConverter
destination type
.readValue
in interface RelationalConverter
readValue
in class BasicRelationalConverter
value
- a value as it is returned by the driver accessing the persistence store. May be null
.type
- TypeInformation
into which the value is to be converted. Must not be null
.null
.@Nullable public Object writeValue(@Nullable Object value, TypeInformation<?> type)
RelationalConverter
writeValue
in interface RelationalConverter
writeValue
in class BasicRelationalConverter
value
- a value as it is used in the object model. May be null
.type
- TypeInformation
into which the value is to be converted. Must not be null
.null
.public JdbcValue writeJdbcValue(@Nullable Object value, Class<?> columnType, int sqlType)
JdbcConverter
JdbcValue
that contains the converted value and information how to bind it
to JDBC parameters.writeJdbcValue
in interface JdbcConverter
value
- a value as it is used in the object model. May be null
.columnType
- TypeInformation
into which the value is to be converted. Must not be null
.sqlType
- the type constant from Types
to be used if non is specified by a converter.JdbcValue
. Guaranteed to be not null.public <T> T mapRow(RelationalPersistentEntity<T> entity, ResultSet resultSet, Object key)
JdbcConverter
mapRow
in interface JdbcConverter
entity
- the persistent entity type.resultSet
- the ResultSet
to read from.key
- primary key.public <T> T mapRow(PersistentPropertyPathExtension path, ResultSet resultSet, Identifier identifier, Object key)
JdbcConverter
mapRow
in interface JdbcConverter
path
- path to the owning property.resultSet
- the ResultSet
to read from.identifier
- entity identifier.key
- primary key.Copyright © 2017–2020 Pivotal Software, Inc.. All rights reserved.