Class BasicJdbcConverter
java.lang.Object
org.springframework.data.relational.core.conversion.BasicRelationalConverter
org.springframework.data.jdbc.core.convert.BasicJdbcConverter
- All Implemented Interfaces:
Aware,ApplicationContextAware,JdbcConverter,RelationalConverter
public class BasicJdbcConverter
extends BasicRelationalConverter
implements JdbcConverter, ApplicationContextAware
RelationalConverter that uses a MappingContext to apply basic conversion of relational values to
property values.
Conversion is configurable by providing a customized CustomConversions.
- Since:
- 1.1
- Author:
- Mark Paluch, Jens Schauder, Christoph Strobl, Myeonghyeon Lee, Chirag Tailor
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionBasicJdbcConverter(MappingContext<? extends RelationalPersistentEntity<?>, ? extends RelationalPersistentProperty> context, RelationResolver relationResolver) Creates a newBasicRelationalConvertergivenMappingContextand ano-op type factorythrowingUnsupportedOperationExceptionon type creation.BasicJdbcConverter(MappingContext<? extends RelationalPersistentEntity<?>, ? extends RelationalPersistentProperty> context, RelationResolver relationResolver, CustomConversions conversions, JdbcTypeFactory typeFactory, IdentifierProcessing identifierProcessing) Creates a newBasicRelationalConvertergivenMappingContext. -
Method Summary
Modifier and TypeMethodDescriptionClass<?>getColumnType(RelationalPersistentProperty property) The type to be used to store this property in the database.getTargetSqlType(RelationalPersistentProperty property) The SQL type constant used when using this property as a parameter for a SQL statement.<T> TmapRow(PersistentPropertyPathExtension path, ResultSet resultSet, Identifier identifier, Object key) <T> TmapRow(RelationalPersistentEntity<T> entity, ResultSet resultSet, Object key) readValue(Object value, TypeInformation<?> type) voidsetApplicationContext(ApplicationContext applicationContext) writeJdbcValue(Object value, Class<?> columnType, SQLType sqlType) Convert a property value into aJdbcValuethat contains the converted value and information how to bind it to JDBC parameters.writeValue(Object value, TypeInformation<?> type) Methods inherited from class org.springframework.data.relational.core.conversion.BasicRelationalConverter
createInstance, getConversions, getConversionService, getEntityInstantiators, getMappingContext, getPropertyAccessorMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.data.relational.core.conversion.RelationalConverter
createInstance, getConversionService, getEntityInstantiators, getMappingContext, getPropertyAccessor
-
Constructor Details
-
BasicJdbcConverter
public BasicJdbcConverter(MappingContext<? extends RelationalPersistentEntity<?>, ? extends RelationalPersistentProperty> context, RelationResolver relationResolver) Creates a newBasicRelationalConvertergivenMappingContextand ano-op type factorythrowingUnsupportedOperationExceptionon type creation. UseBasicJdbcConverter(MappingContext, RelationResolver, CustomConversions, JdbcTypeFactory, IdentifierProcessing)(MappingContext, RelationResolver, JdbcTypeFactory)} to convert arrays and large objects into JDBC-specific types.- Parameters:
context- must not be null.relationResolver- used to fetch additional relations from the database. Must not be null.
-
BasicJdbcConverter
public BasicJdbcConverter(MappingContext<? extends RelationalPersistentEntity<?>, ? extends RelationalPersistentProperty> context, RelationResolver relationResolver, CustomConversions conversions, JdbcTypeFactory typeFactory, IdentifierProcessing identifierProcessing) Creates a newBasicRelationalConvertergivenMappingContext.- Parameters:
context- must not be null.relationResolver- used to fetch additional relations from the database. Must not be null.typeFactory- must not be nullidentifierProcessing- must not be null- Since:
- 2.0
-
-
Method Details
-
setApplicationContext
- Specified by:
setApplicationContextin interfaceApplicationContextAware
-
getTargetSqlType
Description copied from interface:JdbcConverterThe SQL type constant used when using this property as a parameter for a SQL statement.- Specified by:
getTargetSqlTypein interfaceJdbcConverter- Returns:
- Must not be
null. - See Also:
-
getColumnType
Description copied from interface:JdbcConverterThe type to be used to store this property in the database. Multidimensional arrays are unwrapped to reflect a top-level array type (e.g.String[][]returnsString[]).- Specified by:
getColumnTypein interfaceJdbcConverter- Returns:
- a
Classthat is suitable for usage with JDBC drivers. - See Also:
-
readValue
- Specified by:
readValuein interfaceRelationalConverter- Overrides:
readValuein classBasicRelationalConverter
-
writeValue
- Specified by:
writeValuein interfaceRelationalConverter- Overrides:
writeValuein classBasicRelationalConverter
-
writeJdbcValue
Description copied from interface:JdbcConverterConvert a property value into aJdbcValuethat contains the converted value and information how to bind it to JDBC parameters.- Specified by:
writeJdbcValuein interfaceJdbcConverter- Parameters:
value- a value as it is used in the object model. May benull.columnType- Class into which the value is to be converted. Must not benull.sqlType- theSQLTypeto be used if non is specified by a converter.- Returns:
- The converted value wrapped in a
JdbcValue. Guaranteed to be not null.
-
mapRow
Description copied from interface:JdbcConverter- Specified by:
mapRowin interfaceJdbcConverter- Parameters:
entity- the persistent entity type.resultSet- theResultSetto read from.key- primary key.- Returns:
-
mapRow
public <T> T mapRow(PersistentPropertyPathExtension path, ResultSet resultSet, Identifier identifier, Object key) Description copied from interface:JdbcConverter- Specified by:
mapRowin interfaceJdbcConverter- Parameters:
path- path to the owning property.resultSet- theResultSetto read from.identifier- entity identifier.key- primary key.- Returns:
-