Skip to content

SimpleJdbcRepository::saveAll no longer accepts empty list #1401

@hansson

Description

@hansson

When migrating some projects to Spring Boot 3.0.1 I've noticed that there has been a change of the behavior of org.springframework.data.jdbc.repository.support.SimpleJdbcRepository::saveAll. In the old implementation it was allowed to send an empty list to saveAll but now it will fail with an exception.

New implementation

public <S extends T> Iterable<S> saveAll(Iterable<S> entities) {
	return entityOperations.saveAll(entities); //Throws exception on empty list
}

Previous implementation

public <S extends T> Iterable<S> saveAll(Iterable<S> entities) {
		return Streamable.of(entities).stream() //
				.map(this::save) //
				.collect(Collectors.toList());
}

Would it maybe be possible to keep the old behavior with an early return if the list is empty? This can of course be changed in the applications that calls saveAll but I feel like it sometimes can be a quite subtle error that might be hard to spot when migrating to a new version of Spring.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: regressionA regression from a previous release

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions