diff --git a/pom.xml b/pom.xml
index fe60487ec8..3181bc4eb1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
org.springframework.data
spring-data-relational-parent
- 1.1.0.BUILD-SNAPSHOT
+ 1.1.0.DATAJDBC-326-SNAPSHOT
pom
Spring Data Relational Parent
diff --git a/spring-data-jdbc-distribution/pom.xml b/spring-data-jdbc-distribution/pom.xml
index 1753776a73..d987c51da0 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
- 1.1.0.BUILD-SNAPSHOT
+ 1.1.0.DATAJDBC-326-SNAPSHOT
../pom.xml
diff --git a/spring-data-jdbc/pom.xml b/spring-data-jdbc/pom.xml
index 9458230173..9a1158979d 100644
--- a/spring-data-jdbc/pom.xml
+++ b/spring-data-jdbc/pom.xml
@@ -5,7 +5,7 @@
4.0.0
spring-data-jdbc
- 1.1.0.BUILD-SNAPSHOT
+ 1.1.0.DATAJDBC-326-SNAPSHOT
Spring Data JDBC
Spring Data module for JDBC repositories.
@@ -14,7 +14,7 @@
org.springframework.data
spring-data-relational-parent
- 1.1.0.BUILD-SNAPSHOT
+ 1.1.0.DATAJDBC-326-SNAPSHOT
diff --git a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/CascadingDataAccessStrategy.java b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/CascadingDataAccessStrategy.java
index 7edb996ce6..f78dc5bd35 100644
--- a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/CascadingDataAccessStrategy.java
+++ b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/CascadingDataAccessStrategy.java
@@ -21,6 +21,7 @@
import java.util.function.Consumer;
import java.util.function.Function;
+import org.springframework.data.relational.domain.Identifier;
import org.springframework.data.mapping.PersistentPropertyPath;
import org.springframework.data.relational.core.mapping.RelationalPersistentProperty;
@@ -47,6 +48,15 @@ public Object insert(T instance, Class domainType, Map ad
return collect(das -> das.insert(instance, domainType, additionalParameters));
}
+ /*
+ * (non-Javadoc)
+ * @see org.springframework.data.jdbc.core.DataAccessStrategy#insert(java.lang.Object, java.lang.Class, org.springframework.data.jdbc.core.ParentKeys)
+ */
+ @Override
+ public Object insert(T instance, Class domainType, Identifier identifier) {
+ return collect(das -> das.insert(instance, domainType, identifier));
+ }
+
/*
* (non-Javadoc)
* @see org.springframework.data.jdbc.core.DataAccessStrategy#update(java.lang.Object, java.lang.Class)
@@ -149,7 +159,7 @@ public boolean existsById(Object id, Class domainType) {
private T collect(Function function) {
// Keep as Eclipse fails to compile if <> is used.
- return strategies.stream().collect(new FunctionCollector(function));
+ return strategies.stream().collect(new FunctionCollector<>(function));
}
private void collectVoid(Consumer consumer) {
diff --git a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/DataAccessStrategy.java b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/DataAccessStrategy.java
index a307b8b2d0..1ff274c26d 100644
--- a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/DataAccessStrategy.java
+++ b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/DataAccessStrategy.java
@@ -19,6 +19,7 @@
import org.springframework.data.mapping.PersistentPropertyPath;
import org.springframework.data.relational.core.mapping.RelationalPersistentProperty;
+import org.springframework.data.relational.domain.Identifier;
import org.springframework.lang.Nullable;
/**
@@ -39,9 +40,27 @@ public interface DataAccessStrategy {
* to get referenced are contained in this map. Must not be {@code null}.
* @param the type of the instance.
* @return the id generated by the database if any.
+ * @deprecated since 1.1, use {@link #insert(Object, Class, Identifier)} instead.
*/
+ @Deprecated
Object insert(T instance, Class domainType, Map additionalParameters);
+ /**
+ * Inserts a the data of a single entity. Referenced entities don't get handled.
+ *
+ * @param instance the instance to be stored. Must not be {@code null}.
+ * @param domainType the type of the instance. Must not be {@code null}.
+ * @param identifier information about data that needs to be considered for the insert but which is not part of the
+ * entity. Namely references back to a parent entity and key/index columns for entities that are stored in a
+ * {@link Map} or {@link java.util.List}.
+ * @param the type of the instance.
+ * @return the id generated by the database if any.
+ * @since 1.1
+ */
+ default Object insert(T instance, Class domainType, Identifier identifier){
+ return insert(instance, domainType, identifier.toMap());
+ }
+
/**
* Updates the data of a single entity in the database. Referenced entities don't get handled.
*
diff --git a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/DefaultDataAccessStrategy.java b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/DefaultDataAccessStrategy.java
index 7ee0cf8390..4b3a48cfc0 100644
--- a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/DefaultDataAccessStrategy.java
+++ b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/DefaultDataAccessStrategy.java
@@ -37,6 +37,7 @@
import org.springframework.data.relational.core.mapping.RelationalMappingContext;
import org.springframework.data.relational.core.mapping.RelationalPersistentEntity;
import org.springframework.data.relational.core.mapping.RelationalPersistentProperty;
+import org.springframework.data.relational.domain.Identifier;
import org.springframework.data.util.ClassTypeInformation;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
@@ -57,10 +58,6 @@
@RequiredArgsConstructor
public class DefaultDataAccessStrategy implements DataAccessStrategy {
- private static final String ENTITY_NEW_AFTER_INSERT = "Entity [%s] still 'new' after insert. Please set either"
- + " the id property in a BeforeInsert event handler, or ensure the database creates a value and your "
- + "JDBC driver returns it.";
-
private final @NonNull SqlGeneratorSource sqlGeneratorSource;
private final @NonNull RelationalMappingContext context;
private final @NonNull RelationalConverter converter;
@@ -87,10 +84,23 @@ public DefaultDataAccessStrategy(SqlGeneratorSource sqlGeneratorSource, Relation
*/
@Override
public Object insert(T instance, Class domainType, Map additionalParameters) {
+ return insert(instance, domainType, Identifier.from(additionalParameters));
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.springframework.data.jdbc.core.DataAccessStrategy#insert(java.lang.Object, java.lang.Class, java.util.Map)
+ */
+ @Override
+ public Object insert(T instance, Class domainType, Identifier identifier) {
KeyHolder holder = new GeneratedKeyHolder();
RelationalPersistentEntity persistentEntity = getRequiredPersistentEntity(domainType);
- Map parameters = new LinkedHashMap<>(additionalParameters);
+
+ Map parameters = new LinkedHashMap<>(identifier.size());
+ identifier.forEach((name, value, type) -> {
+ parameters.put(name, converter.writeValue(value, ClassTypeInformation.from(type)));
+ });
MapSqlParameterSource parameterSource = getPropertyMap(instance, persistentEntity, "");
@@ -282,7 +292,8 @@ public boolean existsById(Object id, Class domainType) {
return result;
}
- private MapSqlParameterSource getPropertyMap(final S instance, RelationalPersistentEntity persistentEntity, String prefix) {
+ private MapSqlParameterSource getPropertyMap(S instance, RelationalPersistentEntity persistentEntity,
+ String prefix) {
MapSqlParameterSource parameters = new MapSqlParameterSource();
@@ -294,23 +305,26 @@ private MapSqlParameterSource getPropertyMap(final S instance, Relational
return;
}
- if(property.isEmbedded()){
+ if (property.isEmbedded()) {
Object value = propertyAccessor.getProperty(property);
- final RelationalPersistentEntity> embeddedEntity = context.getPersistentEntity(property.getType());
- final MapSqlParameterSource additionalParameters = getPropertyMap((T)value, (RelationalPersistentEntity) embeddedEntity, prefix + property.getEmbeddedPrefix());
+ RelationalPersistentEntity> embeddedEntity = context.getPersistentEntity(property.getType());
+ MapSqlParameterSource additionalParameters = getPropertyMap((T) value,
+ (RelationalPersistentEntity) embeddedEntity, prefix + property.getEmbeddedPrefix());
parameters.addValues(additionalParameters.getValues());
} else {
Object value = propertyAccessor.getProperty(property);
Object convertedValue = convertForWrite(property, value);
- parameters.addValue(prefix + property.getColumnName(), convertedValue, JdbcUtil.sqlTypeFor(property.getColumnType()));
+ parameters.addValue(prefix + property.getColumnName(), convertedValue,
+ JdbcUtil.sqlTypeFor(property.getColumnType()));
}
});
return parameters;
}
+
@Nullable
private Object convertForWrite(RelationalPersistentProperty property, @Nullable Object value) {
@@ -327,9 +341,8 @@ private Object convertForWrite(RelationalPersistentProperty property, @Nullable
String typeName = JDBCType.valueOf(JdbcUtil.sqlTypeFor(componentType)).getName();
- return operations.getJdbcOperations().execute(
- (Connection c) -> c.createArrayOf(typeName, (Object[]) convertedValue)
- );
+ return operations.getJdbcOperations()
+ .execute((Connection c) -> c.createArrayOf(typeName, (Object[]) convertedValue));
}
@SuppressWarnings("unchecked")
@@ -354,22 +367,22 @@ private static boolean isIdPropertyNullOrScalarZero(@Nullable ID idValue
@Nullable
private Object getIdFromHolder(KeyHolder holder, RelationalPersistentEntity persistentEntity) {
- try {
- // MySQL just returns one value with a special name
- return holder.getKey();
- } catch (DataRetrievalFailureException | InvalidDataAccessApiUsageException e) {
- // Postgres returns a value for each column
+ try {
+ // MySQL just returns one value with a special name
+ return holder.getKey();
+ } catch (DataRetrievalFailureException | InvalidDataAccessApiUsageException e) {
+ // Postgres returns a value for each column
// MS SQL Server returns a value that might be null.
- Map keys = holder.getKeys();
+ Map keys = holder.getKeys();
- if (keys == null || persistentEntity.getIdProperty() == null) {
- return null;
- }
+ if (keys == null || persistentEntity.getIdProperty() == null) {
+ return null;
+ }
- return keys.get(persistentEntity.getIdColumn());
- }
- }
+ return keys.get(persistentEntity.getIdColumn());
+ }
+ }
private EntityRowMapper> getEntityRowMapper(Class> domainType) {
return new EntityRowMapper<>(getRequiredPersistentEntity(domainType), context, converter, accessStrategy);
diff --git a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/DefaultJdbcInterpreter.java b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/DefaultJdbcInterpreter.java
index ea6c6603f0..ab15fd7129 100644
--- a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/DefaultJdbcInterpreter.java
+++ b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/DefaultJdbcInterpreter.java
@@ -18,9 +18,9 @@
import lombok.RequiredArgsConstructor;
import java.util.Collections;
-import java.util.HashMap;
import java.util.Map;
+import org.springframework.data.jdbc.core.convert.JdbcIdentifierBuilder;
import org.springframework.data.mapping.PersistentPropertyPath;
import org.springframework.data.relational.core.conversion.DbAction;
import org.springframework.data.relational.core.conversion.DbAction.Delete;
@@ -36,6 +36,7 @@
import org.springframework.data.relational.core.mapping.RelationalMappingContext;
import org.springframework.data.relational.core.mapping.RelationalPersistentEntity;
import org.springframework.data.relational.core.mapping.RelationalPersistentProperty;
+import org.springframework.data.relational.domain.Identifier;
import org.springframework.lang.Nullable;
/**
@@ -58,7 +59,7 @@ class DefaultJdbcInterpreter implements Interpreter {
@Override
public void interpret(Insert insert) {
- Object id = accessStrategy.insert(insert.getEntity(), insert.getEntityType(), createAdditionalColumnValues(insert));
+ Object id = accessStrategy.insert(insert.getEntity(), insert.getEntityType(), getParentKeys(insert));
insert.setGeneratedId(id);
}
@@ -101,7 +102,7 @@ public void interpret(Merge merge) {
// temporary implementation
if (!accessStrategy.update(merge.getEntity(), merge.getEntityType())) {
- accessStrategy.insert(merge.getEntity(), merge.getEntityType(), createAdditionalColumnValues(merge));
+ accessStrategy.insert(merge.getEntity(), merge.getEntityType(), getParentKeys(merge));
}
}
@@ -141,27 +142,22 @@ public void interpret(DeleteAllRoot deleteAllRoot) {
accessStrategy.deleteAll(deleteAllRoot.getEntityType());
}
- private Map createAdditionalColumnValues(DbAction.WithDependingOn action) {
-
- Map additionalColumnValues = new HashMap<>();
- addDependingOnInformation(action, additionalColumnValues);
- additionalColumnValues.putAll(action.getAdditionalValues());
-
- return additionalColumnValues;
- }
-
- private void addDependingOnInformation(DbAction.WithDependingOn action,
- Map additionalColumnValues) {
+ private Identifier getParentKeys(DbAction.WithDependingOn> action) {
DbAction.WithEntity> dependingOn = action.getDependingOn();
RelationalPersistentEntity> persistentEntity = context.getRequiredPersistentEntity(dependingOn.getEntityType());
- String columnName = getColumnNameForReverseColumn(action);
+ Object id = getIdFromEntityDependingOn(dependingOn, persistentEntity);
+ JdbcIdentifierBuilder identifier = JdbcIdentifierBuilder //
+ .forBackReferences(action.getPropertyPath(), id);
- Object identifier = getIdFromEntityDependingOn(dependingOn, persistentEntity);
+ for (Map.Entry, Object> qualifier : action.getQualifiers()
+ .entrySet()) {
+ identifier = identifier.withQualifier(qualifier.getKey(), qualifier.getValue());
+ }
- additionalColumnValues.put(columnName, identifier);
+ return identifier.build();
}
@Nullable
@@ -182,9 +178,4 @@ private Object getIdFromEntityDependingOn(DbAction.WithEntity> dependingOn,
return persistentEntity.getIdentifierAccessor(entity).getIdentifier();
}
- private String getColumnNameForReverseColumn(DbAction.WithPropertyPath> action) {
-
- PersistentPropertyPath path = action.getPropertyPath();
- return path.getRequiredLeafProperty().getReverseColumnName();
- }
}
diff --git a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/DelegatingDataAccessStrategy.java b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/DelegatingDataAccessStrategy.java
index 0a833f30e4..67382311eb 100644
--- a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/DelegatingDataAccessStrategy.java
+++ b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/DelegatingDataAccessStrategy.java
@@ -17,6 +17,7 @@
import java.util.Map;
+import org.springframework.data.relational.domain.Identifier;
import org.springframework.data.mapping.PersistentPropertyPath;
import org.springframework.data.relational.core.mapping.RelationalPersistentProperty;
import org.springframework.util.Assert;
@@ -40,6 +41,15 @@ public Object insert(T instance, Class domainType, Map ad
return delegate.insert(instance, domainType, additionalParameters);
}
+ /*
+ * (non-Javadoc)
+ * @see org.springframework.data.jdbc.core.DataAccessStrategy#insert(java.lang.Object, java.lang.Class, org.springframework.data.jdbc.core.ParentKeys)
+ */
+ @Override
+ public Object insert(T instance, Class domainType, Identifier identifier) {
+ return delegate.insert(instance, domainType, identifier);
+ }
+
/*
* (non-Javadoc)
* @see org.springframework.data.jdbc.core.DataAccessStrategy#update(java.lang.Object, java.lang.Class)
diff --git a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/BasicJdbcConverter.java b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/BasicJdbcConverter.java
index 5680a51ba2..e94f91bf92 100644
--- a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/BasicJdbcConverter.java
+++ b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/BasicJdbcConverter.java
@@ -20,17 +20,23 @@
import org.springframework.core.convert.ConverterNotFoundException;
import org.springframework.data.convert.CustomConversions;
import org.springframework.data.jdbc.core.mapping.AggregateReference;
+import org.springframework.data.mapping.PersistentPropertyPath;
import org.springframework.data.mapping.context.MappingContext;
import org.springframework.data.mapping.model.SimpleTypeHolder;
import org.springframework.data.relational.core.conversion.BasicRelationalConverter;
import org.springframework.data.relational.core.conversion.RelationalConverter;
import org.springframework.data.relational.core.mapping.RelationalPersistentEntity;
import org.springframework.data.relational.core.mapping.RelationalPersistentProperty;
+import org.springframework.data.relational.domain.Identifier;
import org.springframework.data.util.TypeInformation;
import org.springframework.lang.Nullable;
import java.sql.Array;
import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
/**
* {@link RelationalConverter} that uses a {@link MappingContext} to apply basic conversion of relational values to
@@ -122,4 +128,6 @@ public Object writeValue(@Nullable Object value, TypeInformation> type) {
return super.writeValue(value, type);
}
+
+
}
diff --git a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/JdbcIdentifierBuilder.java b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/JdbcIdentifierBuilder.java
new file mode 100644
index 0000000000..1757df32f1
--- /dev/null
+++ b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/JdbcIdentifierBuilder.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.data.jdbc.core.convert;
+
+import org.springframework.data.mapping.PersistentPropertyPath;
+import org.springframework.data.relational.core.mapping.RelationalPersistentProperty;
+import org.springframework.data.relational.domain.Identifier;
+import org.springframework.lang.Nullable;
+
+/**
+ * Builder for {@link Identifier}. Mainly for internal use within the framework
+ *
+ * @author Jens Schauder
+ * @since 1.1
+ */
+public class JdbcIdentifierBuilder {
+
+ private Identifier identifier;
+
+ private JdbcIdentifierBuilder(Identifier identifier) {
+ this.identifier = identifier;
+ }
+
+ public static JdbcIdentifierBuilder empty() {
+ return new JdbcIdentifierBuilder(Identifier.empty());
+ }
+
+ /**
+ * Creates ParentKeys with backreference for the given path and value of the parents id.
+ */
+ public static JdbcIdentifierBuilder forBackReferences(PersistentPropertyPath path,
+ @Nullable Object value) {
+
+ Identifier identifier = Identifier.of( //
+ path.getRequiredLeafProperty().getReverseColumnName(), //
+ value, //
+ getLastIdProperty(path).getColumnType() //
+ );
+
+ return new JdbcIdentifierBuilder(identifier);
+ }
+
+ public JdbcIdentifierBuilder withQualifier(PersistentPropertyPath path, Object value) {
+
+ RelationalPersistentProperty leafProperty = path.getRequiredLeafProperty();
+ identifier = identifier.withPart(leafProperty.getKeyColumn(), value, leafProperty.getQualifierColumnType());
+
+ return this;
+ }
+
+ public Identifier build() {
+ return identifier;
+ }
+
+ private static RelationalPersistentProperty getLastIdProperty(
+ PersistentPropertyPath path) {
+
+ RelationalPersistentProperty idProperty = path.getRequiredLeafProperty().getOwner().getIdProperty();
+
+ if (idProperty != null) {
+ return idProperty;
+ }
+
+ return getLastIdProperty(path.getParentPath());
+ }
+}
diff --git a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/mybatis/MyBatisDataAccessStrategy.java b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/mybatis/MyBatisDataAccessStrategy.java
index 9618455805..0677a15e3e 100644
--- a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/mybatis/MyBatisDataAccessStrategy.java
+++ b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/mybatis/MyBatisDataAccessStrategy.java
@@ -22,6 +22,7 @@
import org.apache.ibatis.session.SqlSession;
import org.mybatis.spring.SqlSessionTemplate;
+
import org.springframework.data.jdbc.core.CascadingDataAccessStrategy;
import org.springframework.data.jdbc.core.DataAccessStrategy;
import org.springframework.data.jdbc.core.DefaultDataAccessStrategy;
@@ -32,6 +33,7 @@
import org.springframework.data.relational.core.conversion.RelationalConverter;
import org.springframework.data.relational.core.mapping.RelationalMappingContext;
import org.springframework.data.relational.core.mapping.RelationalPersistentProperty;
+import org.springframework.data.relational.domain.Identifier;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations;
import org.springframework.util.Assert;
@@ -123,7 +125,7 @@ public void setNamespaceStrategy(NamespaceStrategy namespaceStrategy) {
this.namespaceStrategy = namespaceStrategy;
}
- /*
+ /*
* (non-Javadoc)
* @see org.springframework.data.jdbc.core.DataAccessStrategy#insert(java.lang.Object, java.lang.Class, java.util.Map)
*/
@@ -136,7 +138,20 @@ public Object insert(T instance, Class domainType, Map ad
return myBatisContext.getId();
}
- /*
+ /*
+ * (non-Javadoc)
+ * @see org.springframework.data.jdbc.core.DataAccessStrategy#insert(java.lang.Object, java.lang.Class, ParentKeys)
+ */
+ @Override
+ public Object insert(T instance, Class domainType, Identifier identifier) {
+
+ MyBatisContext myBatisContext = new MyBatisContext(null, instance, domainType, identifier.toMap());
+ sqlSession().insert(namespace(domainType) + ".insert", myBatisContext);
+
+ return myBatisContext.getId();
+ }
+
+ /*
* (non-Javadoc)
* @see org.springframework.data.jdbc.core.DataAccessStrategy#update(java.lang.Object, java.lang.Class)
*/
@@ -147,7 +162,7 @@ public boolean update(S instance, Class domainType) {
new MyBatisContext(null, instance, domainType, Collections.emptyMap())) != 0;
}
- /*
+ /*
* (non-Javadoc)
* @see org.springframework.data.jdbc.core.DataAccessStrategy#delete(java.lang.Object, java.lang.Class)
*/
@@ -158,7 +173,7 @@ public void delete(Object id, Class> domainType) {
new MyBatisContext(id, null, domainType, Collections.emptyMap()));
}
- /*
+ /*
* (non-Javadoc)
* @see org.springframework.data.jdbc.core.DataAccessStrategy#delete(java.lang.Object, org.springframework.data.mapping.PersistentPropertyPath)
*/
@@ -171,7 +186,7 @@ public void delete(Object rootId, PersistentPropertyPath void deleteAll(Class domainType) {
);
}
- /*
+ /*
* (non-Javadoc)
* @see org.springframework.data.jdbc.core.DataAccessStrategy#deleteAll(org.springframework.data.mapping.PersistentPropertyPath)
*/
@@ -200,7 +215,7 @@ public void deleteAll(PersistentPropertyPath prope
);
}
- /*
+ /*
* (non-Javadoc)
* @see org.springframework.data.jdbc.core.DataAccessStrategy#findById(java.lang.Object, java.lang.Class)
*/
@@ -210,7 +225,7 @@ public T findById(Object id, Class domainType) {
new MyBatisContext(id, null, domainType, Collections.emptyMap()));
}
- /*
+ /*
* (non-Javadoc)
* @see org.springframework.data.jdbc.core.DataAccessStrategy#findAll(java.lang.Class)
*/
@@ -220,7 +235,7 @@ public Iterable findAll(Class domainType) {
new MyBatisContext(null, null, domainType, Collections.emptyMap()));
}
- /*
+ /*
* (non-Javadoc)
* @see org.springframework.data.jdbc.core.DataAccessStrategy#findAllById(java.lang.Iterable, java.lang.Class)
*/
@@ -230,7 +245,7 @@ public Iterable findAllById(Iterable> ids, Class domainType) {
new MyBatisContext(ids, null, domainType, Collections.emptyMap()));
}
- /*
+ /*
* (non-Javadoc)
* @see org.springframework.data.jdbc.core.DataAccessStrategy#findAllByProperty(java.lang.Object, org.springframework.data.relational.core.mapping.RelationalPersistentProperty)
*/
@@ -241,7 +256,7 @@ public Iterable findAllByProperty(Object rootId, RelationalPersistentProp
new MyBatisContext(rootId, null, property.getType(), Collections.emptyMap()));
}
- /*
+ /*
* (non-Javadoc)
* @see org.springframework.data.jdbc.core.DataAccessStrategy#existsById(java.lang.Object, java.lang.Class)
*/
@@ -251,7 +266,7 @@ public boolean existsById(Object id, Class domainType) {
new MyBatisContext(id, null, domainType, Collections.emptyMap()));
}
- /*
+ /*
* (non-Javadoc)
* @see org.springframework.data.jdbc.core.DataAccessStrategy#count(java.lang.Class)
*/
diff --git a/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/DefaultJdbcInterpreterUnitTests.java b/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/DefaultJdbcInterpreterUnitTests.java
index 1029746cea..164a8b3355 100644
--- a/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/DefaultJdbcInterpreterUnitTests.java
+++ b/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/DefaultJdbcInterpreterUnitTests.java
@@ -16,14 +16,12 @@
package org.springframework.data.jdbc.core;
import static org.assertj.core.api.Assertions.*;
-import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.*;
-import java.util.AbstractMap.SimpleEntry;
-import java.util.Map;
-
import org.junit.Test;
import org.mockito.ArgumentCaptor;
+
import org.springframework.data.annotation.Id;
import org.springframework.data.jdbc.core.mapping.JdbcMappingContext;
import org.springframework.data.relational.core.conversion.DbAction.Insert;
@@ -31,6 +29,7 @@
import org.springframework.data.relational.core.mapping.NamingStrategy;
import org.springframework.data.relational.core.mapping.RelationalMappingContext;
import org.springframework.data.relational.core.mapping.RelationalPersistentProperty;
+import org.springframework.data.relational.domain.Identifier;
/**
* Unit tests for {@link DefaultJdbcInterpreter}
@@ -67,10 +66,12 @@ public void insertDoesHonourNamingStrategyForBackReference() {
interpreter.interpret(insert);
- ArgumentCaptor