spring-data-mongodb
spring-data-mongodb copied to clipboard
repository insert collection method call findOne of all items if @Id annotated field is valorized
Java doc of repository insert collection method say :
"Inserts the given entities. Assumes the given entities to have not been persisted yet and thus will optimize the insert over a call to saveAll(Iterable). Prefer using saveAll(Iterable) to avoid the usage of storespecific API."
but if @Id annotated fields of items in collection are pre valorized, repository first check all id and after this, save data but this degrade the performance of a code like this:
repository.deleteAll(); repository.insert(collection);
is this behavior intentional?