spring-data-mongodb icon indicating copy to clipboard operation
spring-data-mongodb copied to clipboard

repository insert collection method call findOne of all items if @Id annotated field is valorized

Open aprato-visual opened this issue 3 years ago • 0 comments

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?

aprato-visual avatar Dec 29 '21 11:12 aprato-visual