diff --git a/pom.xml b/pom.xml
index 02461b8e40..75ea3a8b5f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
org.springframework.data
spring-data-relational-parent
- 3.3.0-SNAPSHOT
+ 3.3.0-GH-1721-SNAPSHOT
pom
Spring Data Relational Parent
diff --git a/spring-data-jdbc-distribution/pom.xml b/spring-data-jdbc-distribution/pom.xml
index 8d987fb028..cc00cf4666 100644
--- a/spring-data-jdbc-distribution/pom.xml
+++ b/spring-data-jdbc-distribution/pom.xml
@@ -14,7 +14,7 @@
org.springframework.data
spring-data-relational-parent
- 3.3.0-SNAPSHOT
+ 3.3.0-GH-1721-SNAPSHOT
../pom.xml
diff --git a/spring-data-jdbc/pom.xml b/spring-data-jdbc/pom.xml
index fddbaab696..200ea116d7 100644
--- a/spring-data-jdbc/pom.xml
+++ b/spring-data-jdbc/pom.xml
@@ -6,7 +6,7 @@
4.0.0
spring-data-jdbc
- 3.3.0-SNAPSHOT
+ 3.3.0-GH-1721-SNAPSHOT
Spring Data JDBC
Spring Data module for JDBC repositories.
@@ -15,7 +15,7 @@
org.springframework.data
spring-data-relational-parent
- 3.3.0-SNAPSHOT
+ 3.3.0-GH-1721-SNAPSHOT
diff --git a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/EntityRowMapper.java b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/EntityRowMapper.java
index 4734435604..e936fb0f07 100644
--- a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/EntityRowMapper.java
+++ b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/EntityRowMapper.java
@@ -79,8 +79,8 @@ public T mapRow(ResultSet resultSet, int rowNumber) throws SQLException {
RowDocument document = RowDocumentResultSetExtractor.toRowDocument(resultSet);
return identifier == null //
- ? converter.readAndResolve(entity.getType(), document) //
- : converter.readAndResolve(entity.getType(), document, identifier);
+ ? converter.readAndResolve(entity.getTypeInformation(), document, Identifier.empty()) //
+ : converter.readAndResolve(entity.getTypeInformation(), document, identifier);
}
}
diff --git a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/JdbcConverter.java b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/JdbcConverter.java
index d97c2a6919..ae5b4aa23e 100644
--- a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/JdbcConverter.java
+++ b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/JdbcConverter.java
@@ -26,6 +26,7 @@
import org.springframework.data.relational.core.mapping.RelationalPersistentEntity;
import org.springframework.data.relational.core.mapping.RelationalPersistentProperty;
import org.springframework.data.relational.domain.RowDocument;
+import org.springframework.data.util.TypeInformation;
import org.springframework.lang.Nullable;
/**
@@ -47,7 +48,21 @@ public interface JdbcConverter extends RelationalConverter {
* @return The converted value wrapped in a {@link JdbcValue}. Guaranteed to be not {@literal null}.
* @since 2.4
*/
- JdbcValue writeJdbcValue(@Nullable Object value, Class> type, SQLType sqlType);
+ default JdbcValue writeJdbcValue(@Nullable Object value, Class> type, SQLType sqlType) {
+ return writeJdbcValue(value, TypeInformation.of(type), sqlType);
+ }
+
+ /**
+ * Convert a property value into a {@link JdbcValue} that contains the converted value and information how to bind it
+ * to JDBC parameters.
+ *
+ * @param value a value as it is used in the object model. May be {@code null}.
+ * @param type {@link TypeInformation} into which the value is to be converted. Must not be {@code null}.
+ * @param sqlType the {@link SQLType} to be used if non is specified by a converter.
+ * @return The converted value wrapped in a {@link JdbcValue}. Guaranteed to be not {@literal null}.
+ * @since 3.2.6
+ */
+ JdbcValue writeJdbcValue(@Nullable Object value, TypeInformation> type, SQLType sqlType);
/**
* Read the current row from {@link ResultSet} to an {@link RelationalPersistentEntity#getType() entity}.
@@ -84,7 +99,7 @@ default T mapRow(RelationalPersistentEntity entity, ResultSet resultSet,
default T mapRow(PersistentPropertyPathExtension path, ResultSet resultSet, Identifier identifier, Object key) {
try {
- return (T) readAndResolve(path.getRequiredLeafEntity().getType(),
+ return (T) readAndResolve(path.getRequiredLeafEntity().getTypeInformation(),
RowDocumentResultSetExtractor.toRowDocument(resultSet), identifier);
} catch (SQLException e) {
throw new RuntimeException(e);
@@ -118,7 +133,23 @@ default R readAndResolve(Class type, RowDocument source) {
* @since 3.2
* @see #read(Class, RowDocument)
*/
- R readAndResolve(Class type, RowDocument source, Identifier identifier);
+ default R readAndResolve(Class type, RowDocument source, Identifier identifier) {
+ return readAndResolve(TypeInformation.of(type), source, identifier);
+ }
+
+ /**
+ * Read a {@link RowDocument} into the requested {@link TypeInformation aggregate type} and resolve references by
+ * looking these up from {@link RelationResolver}.
+ *
+ * @param type target aggregate type.
+ * @param source source {@link RowDocument}.
+ * @param identifier identifier chain.
+ * @return the converted object.
+ * @param aggregate type.
+ * @since 3.2.6
+ * @see #read(Class, RowDocument)
+ */
+ R readAndResolve(TypeInformation type, RowDocument source, Identifier identifier);
/**
* The type to be used to store this property in the database. Multidimensional arrays are unwrapped to reflect a
@@ -126,7 +157,7 @@ default R readAndResolve(Class type, RowDocument source) {
*
* @return a {@link Class} that is suitable for usage with JDBC drivers.
* @see org.springframework.data.jdbc.support.JdbcUtil#targetSqlTypeFor(Class)
- * @since 2.0
+ * @since 2.0 TODO: Introduce variant returning TypeInformation.
*/
Class> getColumnType(RelationalPersistentProperty property);
diff --git a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/Jsr310TimestampBasedConverters.java b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/Jsr310TimestampBasedConverters.java
index 2823273d6c..83256c7b15 100644
--- a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/Jsr310TimestampBasedConverters.java
+++ b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/Jsr310TimestampBasedConverters.java
@@ -33,6 +33,7 @@
import java.util.List;
import org.springframework.core.convert.converter.Converter;
+import org.springframework.data.convert.Jsr310Converters;
import org.springframework.data.convert.ReadingConverter;
import org.springframework.data.convert.WritingConverter;
import org.springframework.lang.NonNull;
@@ -57,7 +58,7 @@ public abstract class Jsr310TimestampBasedConverters {
*/
public static Collection> getConvertersToRegister() {
- List> converters = new ArrayList<>(8);
+ List> converters = new ArrayList<>(28);
converters.add(TimestampToLocalDateTimeConverter.INSTANCE);
converters.add(TimestampToLocalDateConverter.INSTANCE);
@@ -67,6 +68,10 @@ public abstract class Jsr310TimestampBasedConverters {
converters.add(TimestampToInstantConverter.INSTANCE);
converters.add(InstantToTimestampConverter.INSTANCE);
+ // TODO: Install some JSR310 converters to avoid ObjectToObjectConverter usage, such as java.sql.Date ->
+ // LocalDateTime and vice versa
+ // converters.addAll(Jsr310Converters.getConvertersToRegister());
+
return converters;
}
diff --git a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/MapEntityRowMapper.java b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/MapEntityRowMapper.java
index 1c4f28c087..c9e506576e 100644
--- a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/MapEntityRowMapper.java
+++ b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/MapEntityRowMapper.java
@@ -64,7 +64,7 @@ public Map.Entry