Skip to content

Commit 26f0867

Browse files
committed
Add safety against empty lists in batch insert method.
1 parent 16a6cae commit 26f0867

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ public <T> Object insert(T instance, Class<T> domainType, Identifier identifier,
109109
@Override
110110
public <T> Object[] insert(List<RecordDescriptor<T>> recordDescriptors, Class<T> domainType, boolean includeId) {
111111

112+
Assert.notEmpty(recordDescriptors, "recordDescriptors must contain at least one recordDescriptor");
112113
SqlIdentifierParameterSource[] sqlParameterSources = recordDescriptors.stream()
113114
.map(recordDescriptor -> sqlParametersFactory.getInsert(recordDescriptor.getInstance(), domainType, recordDescriptor.getIdentifier()))
114115
.toArray(SqlIdentifierParameterSource[]::new);

0 commit comments

Comments
 (0)