Module spring.data.jdbc
Interface SqlTypeMapping
- All Known Implementing Classes:
DefaultSqlTypeMapping
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Strategy interface for mapping a
RelationalPersistentProperty to a Database type.- Since:
- 3.2
- Author:
- Kurt Niemi, Mark Paluch, Evgenii Koba, Jens Schauder
-
Method Summary
Modifier and TypeMethodDescriptiondefault SqlTypeMappingand(SqlTypeMapping other) Returns a composedSqlTypeMappingthat represents a fallback of this type mapping and another.default StringgetColumnType(Class<?> type) Determines a column type for Class.getColumnType(org.springframework.data.relational.core.mapping.RelationalPersistentProperty property) Determines a column type for a persistent property.default StringgetRequiredColumnType(org.springframework.data.relational.core.mapping.RelationalPersistentProperty property) Returns the required column type for a persistent property or throwsIllegalArgumentExceptionif the type cannot be determined.default booleanisNullable(org.springframework.data.relational.core.mapping.RelationalPersistentProperty property) Determine whether a column is nullable.
-
Method Details
-
getColumnType
@Nullable String getColumnType(org.springframework.data.relational.core.mapping.RelationalPersistentProperty property) Determines a column type for a persistent property.- Parameters:
property- the property for which the type should be determined.- Returns:
- the SQL type to use, such as
VARCHARorNUMERIC. Can be null if the strategy cannot provide a column type.
-
getColumnType
Determines a column type for Class.- Parameters:
type- class for which the type should be determined.- Returns:
- the SQL type to use, such as
VARCHARorNUMERIC. Can be null if the strategy cannot provide a column type. - Since:
- 3.3
-
getRequiredColumnType
default String getRequiredColumnType(org.springframework.data.relational.core.mapping.RelationalPersistentProperty property) Returns the required column type for a persistent property or throwsIllegalArgumentExceptionif the type cannot be determined.- Parameters:
property- the property for which the type should be determined.- Returns:
- the SQL type to use, such as
VARCHARorNUMERIC. Can be null if the strategy cannot provide a column type. - Throws:
IllegalArgumentException- if the column type cannot be determined.
-
isNullable
default boolean isNullable(org.springframework.data.relational.core.mapping.RelationalPersistentProperty property) Determine whether a column is nullable.- Parameters:
property- the property for which nullability should be determined.- Returns:
- whether the property is nullable.
-
and
Returns a composedSqlTypeMappingthat represents a fallback of this type mapping and another. When evaluating the composed predicate, if this mapping does not contain a column mapping (i.e.getColumnType(RelationalPersistentProperty)returnsnull), then theothermapping is evaluated.Any exceptions thrown during evaluation of either type mapping are relayed to the caller; if evaluation of this type mapping throws an exception, the
otherpredicate will not be evaluated.- Parameters:
other- a type mapping that will be used as fallback, must not be null.- Returns:
- a composed type mapping
-