Skip to content

Commit 3434fa8

Browse files
committed
Add includeId parameter to insert method and populate it appropriately when InsertRoot or Insert is created.
1 parent 20d2716 commit 3434fa8

File tree

16 files changed

+245
-182
lines changed

16 files changed

+245
-182
lines changed

spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/JdbcAggregateChangeExecutionContext.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,11 @@ <T> void executeInsertRoot(DbAction.InsertRoot<T> insert) {
8989
T rootEntity = RelationalEntityVersionUtils.setVersionNumberOnEntity( //
9090
insert.getEntity(), initialVersion, persistentEntity, converter);
9191

92-
id = accessStrategy.insert(rootEntity, insert.getEntityType(), Identifier.empty());
92+
id = accessStrategy.insert(rootEntity, insert.getEntityType(), Identifier.empty(), false);
9393

9494
setNewVersion(initialVersion);
9595
} else {
96-
id = accessStrategy.insert(insert.getEntity(), insert.getEntityType(), Identifier.empty());
96+
id = accessStrategy.insert(insert.getEntity(), insert.getEntityType(), Identifier.empty(), false);
9797
}
9898

9999
add(new DbActionExecutionResult(insert, id));
@@ -102,7 +102,7 @@ <T> void executeInsertRoot(DbAction.InsertRoot<T> insert) {
102102
<T> void executeInsert(DbAction.Insert<T> insert) {
103103

104104
Identifier parentKeys = getParentKeys(insert, converter);
105-
Object id = accessStrategy.insert(insert.getEntity(), insert.getEntityType(), parentKeys);
105+
Object id = accessStrategy.insert(insert.getEntity(), insert.getEntityType(), parentKeys, false);
106106
add(new DbActionExecutionResult(insert, id));
107107
}
108108

@@ -113,7 +113,7 @@ <T> void executeInsertBatch(DbAction.InsertBatch<T> insertBatch) {
113113
.map(insert -> RecordDescriptor.of(insert.getEntity(), getParentKeys(insert, converter)))
114114
.collect(Collectors.toList());
115115

116-
Object[] ids = accessStrategy.insert(recordDescriptors, insertBatch.getEntityType(), insertBatch.getIncludeId());
116+
Object[] ids = accessStrategy.insert(recordDescriptors, insertBatch.getEntityType(), insertBatch.isIncludeId());
117117

118118
for (int i = 0; i < inserts.size(); i++) {
119119
add(new DbActionExecutionResult(inserts.get(i), ids.length > 0 ? ids[i] : null));
@@ -176,7 +176,7 @@ <T> void executeMerge(DbAction.Merge<T> merge) {
176176
// temporary implementation
177177
if (!accessStrategy.update(merge.getEntity(), merge.getEntityType())) {
178178

179-
Object id = accessStrategy.insert(merge.getEntity(), merge.getEntityType(), getParentKeys(merge, converter));
179+
Object id = accessStrategy.insert(merge.getEntity(), merge.getEntityType(), getParentKeys(merge, converter), false);
180180
add(new DbActionExecutionResult(merge, id));
181181
} else {
182182
add(new DbActionExecutionResult());

spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/CascadingDataAccessStrategy.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ public CascadingDataAccessStrategy(List<DataAccessStrategy> strategies) {
5050
* @see org.springframework.data.jdbc.core.DataAccessStrategy#insert(java.lang.Object, java.lang.Class, org.springframework.data.jdbc.core.ParentKeys)
5151
*/
5252
@Override
53-
public <T> Object insert(T instance, Class<T> domainType, Identifier identifier) {
54-
return collect(das -> das.insert(instance, domainType, identifier));
53+
public <T> Object insert(T instance, Class<T> domainType, Identifier identifier, boolean includeId) {
54+
return collect(das -> das.insert(instance, domainType, identifier, false));
5555
}
5656

5757
@Override

spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/DataAccessStrategy.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,18 @@ public interface DataAccessStrategy extends RelationResolver {
4242
/**
4343
* Inserts a the data of a single entity. Referenced entities don't get handled.
4444
*
45+
* @param <T> the type of the instance.
4546
* @param instance the instance to be stored. Must not be {@code null}.
4647
* @param domainType the type of the instance. Must not be {@code null}.
4748
* @param identifier information about data that needs to be considered for the insert but which is not part of the
4849
* entity. Namely references back to a parent entity and key/index columns for entities that are stored in a
49-
* {@link Map} or {@link java.util.List}.
50-
* @param <T> the type of the instance.
50+
* {@link Map} or {@link List}.
51+
* @param includeId
5152
* @return the id generated by the database if any.
5253
* @since 1.1
5354
*/
5455
@Nullable
55-
<T> Object insert(T instance, Class<T> domainType, Identifier identifier);
56+
<T> Object insert(T instance, Class<T> domainType, Identifier identifier, boolean includeId);
5657

5758
<T> Object[] insert(List<RecordDescriptor<T>> recordDescriptors, Class<T> domainType, boolean includeId);
5859

spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/DefaultDataAccessStrategy.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public DefaultDataAccessStrategy(SqlGeneratorSource sqlGeneratorSource, Relation
112112
* @see org.springframework.data.jdbc.core.DataAccessStrategy#insert(java.lang.Object, java.lang.Class, java.util.Map)
113113
*/
114114
@Override
115-
public <T> Object insert(T instance, Class<T> domainType, Identifier identifier) {
115+
public <T> Object insert(T instance, Class<T> domainType, Identifier identifier, boolean includeId) {
116116

117117
SqlGenerator sqlGenerator = sql(domainType);
118118
RelationalPersistentEntity<T> persistentEntity = getRequiredPersistentEntity(domainType);
@@ -131,7 +131,7 @@ public <T> Object insert(T instance, Class<T> domainType, Identifier identifier)
131131

132132
String insertSql = sqlGenerator.getInsert(parameterSource.getIdentifiers());
133133

134-
if (idValue == null) {
134+
if (!includeId) {
135135
return executeInsertAndReturnGeneratedId(persistentEntity, parameterSource, insertSql);
136136
} else {
137137

spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/DelegatingDataAccessStrategy.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ public class DelegatingDataAccessStrategy implements DataAccessStrategy {
4343
* @see org.springframework.data.jdbc.core.DataAccessStrategy#insert(java.lang.Object, java.lang.Class, org.springframework.data.jdbc.core.ParentKeys)
4444
*/
4545
@Override
46-
public <T> Object insert(T instance, Class<T> domainType, Identifier identifier) {
47-
return delegate.insert(instance, domainType, identifier);
46+
public <T> Object insert(T instance, Class<T> domainType, Identifier identifier, boolean includeId) {
47+
return delegate.insert(instance, domainType, identifier, false);
4848
}
4949

5050
@Override

spring-data-jdbc/src/main/java/org/springframework/data/jdbc/mybatis/MyBatisDataAccessStrategy.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public void setNamespaceStrategy(NamespaceStrategy namespaceStrategy) {
153153
* @see org.springframework.data.jdbc.core.DataAccessStrategy#insert(java.lang.Object, java.lang.Class, ParentKeys)
154154
*/
155155
@Override
156-
public <T> Object insert(T instance, Class<T> domainType, Identifier identifier) {
156+
public <T> Object insert(T instance, Class<T> domainType, Identifier identifier, boolean includeId) {
157157

158158
MyBatisContext myBatisContext = new MyBatisContext(identifier, instance, domainType);
159159
sqlSession().insert(namespace(domainType) + ".insert", myBatisContext);

spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/AggregateChangeIdGenerationImmutableUnitTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public class AggregateChangeIdGenerationImmutableUnitTests {
6868

6969
RelationalMappingContext context = new RelationalMappingContext();
7070
JdbcConverter converter = mock(JdbcConverter.class);
71-
DbAction.WithEntity<?> rootInsert = new DbAction.InsertRoot<>(entity);
71+
DbAction.WithEntity<?> rootInsert = new DbAction.InsertRoot<>(entity, false);
7272

7373
private DataAccessStrategy accessStrategy = mock(DataAccessStrategy.class);
7474

@@ -393,7 +393,7 @@ DbAction.Insert<?> createInsert(String propertyName, Object value, @Nullable Obj
393393

394394
DbAction.Insert<Object> insert = new DbAction.Insert<>(value,
395395
context.getPersistentPropertyPath(propertyName, DummyEntity.class), rootInsert,
396-
singletonMap(toPath(propertyName), key));
396+
singletonMap(toPath(propertyName), key), false);
397397

398398
return insert;
399399
}
@@ -404,7 +404,7 @@ DbAction.Insert<?> createDeepInsert(String propertyName, Object value, Object ke
404404
PersistentPropertyPath<RelationalPersistentProperty> propertyPath = toPath(
405405
parentInsert.getPropertyPath().toDotPath() + "." + propertyName);
406406
DbAction.Insert<Object> insert = new DbAction.Insert<>(value, propertyPath, parentInsert,
407-
singletonMap(propertyPath, key));
407+
singletonMap(propertyPath, key), false);
408408

409409
return insert;
410410
}

spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/AggregateChangeIdGenerationUnitTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public class AggregateChangeIdGenerationUnitTests {
6161
JdbcConverter converter = new BasicJdbcConverter(context, (identifier, path) -> {
6262
throw new UnsupportedOperationException();
6363
});
64-
DbAction.WithEntity<?> rootInsert = new DbAction.InsertRoot<>(entity);
64+
DbAction.WithEntity<?> rootInsert = new DbAction.InsertRoot<>(entity, false);
6565
DataAccessStrategy accessStrategy = mock(DataAccessStrategy.class, new IncrementingIds());
6666
AggregateChangeExecutor executor = new AggregateChangeExecutor(converter, accessStrategy);
6767

@@ -325,7 +325,7 @@ public void setIdForDeepElementMapElementMap() {
325325
DbAction.Insert<?> createInsert(String propertyName, Object value, @Nullable Object key) {
326326

327327
return new DbAction.Insert<>(value, context.getPersistentPropertyPath(propertyName, DummyEntity.class), rootInsert,
328-
key == null ? emptyMap() : singletonMap(toPath(propertyName), key));
328+
key == null ? emptyMap() : singletonMap(toPath(propertyName), key), false);
329329
}
330330

331331
DbAction.Insert<?> createDeepInsert(String propertyName, Object value, @Nullable Object key,
@@ -335,7 +335,7 @@ DbAction.Insert<?> createDeepInsert(String propertyName, Object value, @Nullable
335335
parentInsert.getPropertyPath().toDotPath() + "." + propertyName);
336336

337337
return new DbAction.Insert<>(value, propertyPath, parentInsert,
338-
key == null ? emptyMap() : singletonMap(propertyPath, key));
338+
key == null ? emptyMap() : singletonMap(propertyPath, key), false);
339339
}
340340

341341
PersistentPropertyPath<RelationalPersistentProperty> toPath(String path) {

spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/JdbcAggregateChangeExecutorContextImmutableUnitTests.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
import org.springframework.data.jdbc.core.convert.Identifier;
3535
import org.springframework.data.jdbc.core.convert.JdbcConverter;
3636
import org.springframework.data.jdbc.core.convert.JdbcIdentifierBuilder;
37-
import org.springframework.data.jdbc.core.convert.RecordDescriptor;
3837
import org.springframework.data.mapping.PersistentPropertyPath;
3938
import org.springframework.data.mapping.PersistentPropertyPaths;
4039
import org.springframework.data.relational.core.conversion.DbAction;
@@ -69,9 +68,9 @@ public void rootOfEmptySetOfActionsisNull() {
6968
public void afterInsertRootIdAndVersionMaybeUpdated() {
7069

7170
// note that the root entity isn't the original one, but a new instance with the version set.
72-
when(accessStrategy.insert(any(DummyEntity.class), eq(DummyEntity.class), eq(Identifier.empty()))).thenReturn(23L);
71+
when(accessStrategy.insert(any(DummyEntity.class), eq(DummyEntity.class), eq(Identifier.empty()), eq(false))).thenReturn(23L);
7372

74-
executionContext.executeInsertRoot(new DbAction.InsertRoot<>(root));
73+
executionContext.executeInsertRoot(new DbAction.InsertRoot<>(root, false));
7574

7675
DummyEntity newRoot = executionContext.populateIdsIfNecessary();
7776

@@ -88,10 +87,10 @@ public void idGenerationOfChild() {
8887

8988
Content content = new Content();
9089

91-
when(accessStrategy.insert(any(DummyEntity.class), eq(DummyEntity.class), eq(Identifier.empty()))).thenReturn(23L);
92-
when(accessStrategy.insert(any(Content.class), eq(Content.class), eq(createBackRef()))).thenReturn(24L);
90+
when(accessStrategy.insert(any(DummyEntity.class), eq(DummyEntity.class), eq(Identifier.empty()), eq(false))).thenReturn(23L);
91+
when(accessStrategy.insert(any(Content.class), eq(Content.class), eq(createBackRef()), eq(false))).thenReturn(24L);
9392

94-
DbAction.InsertRoot<DummyEntity> rootInsert = new DbAction.InsertRoot<>(root);
93+
DbAction.InsertRoot<DummyEntity> rootInsert = new DbAction.InsertRoot<>(root, false);
9594
executionContext.executeInsertRoot(rootInsert);
9695
executionContext.executeInsert(createInsert(rootInsert, "content", content, null));
9796

@@ -108,10 +107,10 @@ public void idGenerationOfChildInList() {
108107

109108
Content content = new Content();
110109

111-
when(accessStrategy.insert(any(DummyEntity.class), eq(DummyEntity.class), eq(Identifier.empty()))).thenReturn(23L);
112-
when(accessStrategy.insert(eq(content), eq(Content.class), any(Identifier.class))).thenReturn(24L);
110+
when(accessStrategy.insert(any(DummyEntity.class), eq(DummyEntity.class), eq(Identifier.empty()), eq(false))).thenReturn(23L);
111+
when(accessStrategy.insert(eq(content), eq(Content.class), any(Identifier.class), eq(false))).thenReturn(24L);
113112

114-
DbAction.InsertRoot<DummyEntity> rootInsert = new DbAction.InsertRoot<>(root);
113+
DbAction.InsertRoot<DummyEntity> rootInsert = new DbAction.InsertRoot<>(root, false);
115114
executionContext.executeInsertRoot(rootInsert);
116115
executionContext.executeInsert(createInsert(rootInsert, "list", content, 1));
117116

@@ -127,7 +126,7 @@ DbAction.Insert<?> createInsert(DbAction.WithEntity<?> parent, String propertyNa
127126
@Nullable Object key) {
128127

129128
DbAction.Insert<Object> insert = new DbAction.Insert<>(value, getPersistentPropertyPath(propertyName), parent,
130-
key == null ? emptyMap() : singletonMap(toPath(propertyName), key));
129+
key == null ? emptyMap() : singletonMap(toPath(propertyName), key), false);
131130

132131
return insert;
133132
}

spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/JdbcAggregateChangeExecutorContextUnitTests.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ public void rootOfEmptySetOfActionsisNull() {
7171
@Test // DATAJDBC-453
7272
public void afterInsertRootIdAndVersionMaybeUpdated() {
7373

74-
when(accessStrategy.insert(root, DummyEntity.class, Identifier.empty())).thenReturn(23L);
74+
when(accessStrategy.insert(root, DummyEntity.class, Identifier.empty(), false)).thenReturn(23L);
7575

76-
executionContext.executeInsertRoot(new DbAction.InsertRoot<>(root));
76+
executionContext.executeInsertRoot(new DbAction.InsertRoot<>(root, false));
7777

7878
DummyEntity newRoot = executionContext.populateIdsIfNecessary();
7979

@@ -90,7 +90,7 @@ public void afterInsertNotPrimitiveVersionShouldBeZero() {
9090

9191
DummyEntityNonPrimitiveVersion dummyEntityNonPrimitiveVersion = new DummyEntityNonPrimitiveVersion();
9292

93-
executionContext.executeInsertRoot(new DbAction.InsertRoot<>(dummyEntityNonPrimitiveVersion));
93+
executionContext.executeInsertRoot(new DbAction.InsertRoot<>(dummyEntityNonPrimitiveVersion, false));
9494
executionContext.populateRootVersionIfNecessary(dummyEntityNonPrimitiveVersion);
9595

9696
assertThat(dummyEntityNonPrimitiveVersion.version).isEqualTo(0);
@@ -101,10 +101,10 @@ public void idGenerationOfChild() {
101101

102102
Content content = new Content();
103103

104-
when(accessStrategy.insert(root, DummyEntity.class, Identifier.empty())).thenReturn(23L);
105-
when(accessStrategy.insert(content, Content.class, createBackRef())).thenReturn(24L);
104+
when(accessStrategy.insert(root, DummyEntity.class, Identifier.empty(), false)).thenReturn(23L);
105+
when(accessStrategy.insert(content, Content.class, createBackRef(), false)).thenReturn(24L);
106106

107-
DbAction.InsertRoot<DummyEntity> rootInsert = new DbAction.InsertRoot<>(root);
107+
DbAction.InsertRoot<DummyEntity> rootInsert = new DbAction.InsertRoot<>(root, false);
108108
executionContext.executeInsertRoot(rootInsert);
109109
executionContext.executeInsert(createInsert(rootInsert, "content", content, null));
110110

@@ -121,10 +121,10 @@ public void idGenerationOfChildInList() {
121121

122122
Content content = new Content();
123123

124-
when(accessStrategy.insert(root, DummyEntity.class, Identifier.empty())).thenReturn(23L);
125-
when(accessStrategy.insert(eq(content), eq(Content.class), any(Identifier.class))).thenReturn(24L);
124+
when(accessStrategy.insert(root, DummyEntity.class, Identifier.empty(), false)).thenReturn(23L);
125+
when(accessStrategy.insert(eq(content), eq(Content.class), any(Identifier.class), eq(false))).thenReturn(24L);
126126

127-
DbAction.InsertRoot<DummyEntity> rootInsert = new DbAction.InsertRoot<>(root);
127+
DbAction.InsertRoot<DummyEntity> rootInsert = new DbAction.InsertRoot<>(root, false);
128128
executionContext.executeInsertRoot(rootInsert);
129129
executionContext.executeInsert(createInsert(rootInsert, "list", content, 1));
130130

@@ -138,9 +138,9 @@ public void idGenerationOfChildInList() {
138138

139139
@Test
140140
void batchInsertOperation_withGeneratedIds() {
141-
when(accessStrategy.insert(root, DummyEntity.class, Identifier.empty())).thenReturn(123L);
141+
when(accessStrategy.insert(root, DummyEntity.class, Identifier.empty(), false)).thenReturn(123L);
142142

143-
DbAction.InsertRoot<DummyEntity> rootInsert = new DbAction.InsertRoot<>(root);
143+
DbAction.InsertRoot<DummyEntity> rootInsert = new DbAction.InsertRoot<>(root, false);
144144
executionContext.executeInsertRoot(rootInsert);
145145

146146
Content content = new Content();
@@ -164,9 +164,9 @@ void batchInsertOperation_withGeneratedIds() {
164164

165165
@Test
166166
void batchInsertOperation_withoutGeneratedIds() {
167-
when(accessStrategy.insert(root, DummyEntity.class, Identifier.empty())).thenReturn(123L);
167+
when(accessStrategy.insert(root, DummyEntity.class, Identifier.empty(), false)).thenReturn(123L);
168168

169-
DbAction.InsertRoot<DummyEntity> rootInsert = new DbAction.InsertRoot<>(root);
169+
DbAction.InsertRoot<DummyEntity> rootInsert = new DbAction.InsertRoot<>(root, false);
170170
executionContext.executeInsertRoot(rootInsert);
171171

172172
Content content = new Content();
@@ -189,10 +189,10 @@ void batchInsertOperation_withoutGeneratedIds() {
189189
}
190190

191191
DbAction.Insert<?> createInsert(DbAction.WithEntity<?> parent, String propertyName, Object value,
192-
@Nullable Object key) {
192+
@Nullable Object key) {
193193

194194
DbAction.Insert<Object> insert = new DbAction.Insert<>(value, getPersistentPropertyPath(propertyName), parent,
195-
key == null ? emptyMap() : singletonMap(toPath(propertyName), key));
195+
key == null ? emptyMap() : singletonMap(toPath(propertyName), key), false);
196196

197197
return insert;
198198
}

spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/convert/DefaultDataAccessStrategyUnitTests.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public void additionalParameterForIdDoesNotLeadToDuplicateParameters() {
101101

102102
additionalParameters.put(SqlIdentifier.quoted("ID"), ID_FROM_ADDITIONAL_VALUES);
103103

104-
accessStrategy.insert(new DummyEntity(ORIGINAL_ID), DummyEntity.class, Identifier.from(additionalParameters));
104+
accessStrategy.insert(new DummyEntity(ORIGINAL_ID), DummyEntity.class, Identifier.from(additionalParameters), true);
105105

106106
verify(namedJdbcOperations).update(eq("INSERT INTO \"DUMMY_ENTITY\" (\"ID\") VALUES (:ID)"),
107107
paramSourceCaptor.capture());
@@ -114,7 +114,7 @@ public void additionalParametersGetAddedToStatement() {
114114

115115
additionalParameters.put(unquoted("reference"), ID_FROM_ADDITIONAL_VALUES);
116116

117-
accessStrategy.insert(new DummyEntity(ORIGINAL_ID), DummyEntity.class, Identifier.from(additionalParameters));
117+
accessStrategy.insert(new DummyEntity(ORIGINAL_ID), DummyEntity.class, Identifier.from(additionalParameters), true);
118118

119119
verify(namedJdbcOperations).update(sqlCaptor.capture(), paramSourceCaptor.capture());
120120

@@ -134,7 +134,7 @@ public void considersConfiguredWriteConverter() {
134134

135135
EntityWithBoolean entity = new EntityWithBoolean(ORIGINAL_ID, true);
136136

137-
accessStrategy.insert(entity, EntityWithBoolean.class, Identifier.empty());
137+
accessStrategy.insert(entity, EntityWithBoolean.class, Identifier.empty(), true);
138138

139139
verify(namedJdbcOperations).update(sqlCaptor.capture(), paramSourceCaptor.capture());
140140

@@ -153,7 +153,7 @@ public void considersConfiguredWriteConverterForIdValueObjects() {
153153
WithValueObjectId entity = new WithValueObjectId(new IdValue(rawId));
154154
entity.value = "vs. superman";
155155

156-
accessStrategy.insert(entity, WithValueObjectId.class, Identifier.empty());
156+
accessStrategy.insert(entity, WithValueObjectId.class, Identifier.empty(), true);
157157

158158
verify(namedJdbcOperations).update(anyString(), paramSourceCaptor.capture());
159159

@@ -180,7 +180,7 @@ public void considersConfiguredWriteConverterForIdValueObjectsWhichReferencedInO
180180
root.dummyEntities.add(child);
181181

182182
additionalParameters.put(SqlIdentifier.quoted("DUMMYENTITYROOT"), rootIdValue);
183-
accessStrategy.insert(root, DummyEntityRoot.class, Identifier.from(additionalParameters));
183+
accessStrategy.insert(root, DummyEntityRoot.class, Identifier.from(additionalParameters), true);
184184

185185
verify(namedJdbcOperations).update(anyString(), paramSourceCaptor.capture());
186186

@@ -199,7 +199,7 @@ public void considersConfiguredWriteConverterForIdValueObjectsWhichReferencedInO
199199
@Test // GH-933
200200
public void insertWithDefinedIdDoesNotRetrieveGeneratedKeys() {
201201

202-
Object generatedId = accessStrategy.insert(new DummyEntity(ORIGINAL_ID), DummyEntity.class, Identifier.from(additionalParameters));
202+
Object generatedId = accessStrategy.insert(new DummyEntity(ORIGINAL_ID), DummyEntity.class, Identifier.from(additionalParameters), true);
203203

204204
assertThat(generatedId).isNull();
205205

@@ -218,7 +218,7 @@ public void insertWithUndefinedIdRetrievesGeneratedKeys() {
218218
return 1;
219219
});
220220

221-
Object generatedId = accessStrategy.insert(new DummyEntity(null), DummyEntity.class, Identifier.from(additionalParameters));
221+
Object generatedId = accessStrategy.insert(new DummyEntity(null), DummyEntity.class, Identifier.from(additionalParameters), false);
222222

223223
assertThat(generatedId).isEqualTo(GENERATED_ID);
224224

spring-data-jdbc/src/test/java/org/springframework/data/jdbc/mybatis/MyBatisDataAccessStrategyUnitTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public void before() {
6767
@Test // DATAJDBC-123
6868
public void insert() {
6969

70-
accessStrategy.insert("x", String.class, Identifier.from(singletonMap(unquoted("key"), "value")));
70+
accessStrategy.insert("x", String.class, Identifier.from(singletonMap(unquoted("key"), "value")), false);
7171

7272
verify(session).insert(eq("java.lang.StringMapper.insert"), captor.capture());
7373

0 commit comments

Comments
 (0)