現在、オブジェクトのコレクションを反復処理して、1 つずつ保存しています。コレクション全体を直接保存する方法があると思いますか?
後で個々のオブジェクトを取得できる必要があることに注意してください (コレクション全体ではありません)。
DataStore クラスの javadoc から。古いバージョンでは使用できない場合があります。これでも、内部的に反復して一度に 1 つずつ保存していると思いますが、最適化される可能性があるため、自分で反復するよりもこれを使用することをお勧めします。
<T> Iterable<Key<T>>
save(Iterable<T> entities)
Saves the entities (Objects) and updates the @Id field
<T> Iterable<Key<T>>
save(Iterable<T> entities, com.mongodb.WriteConcern wc)
Saves the entities (Objects) and updates the @Id field, with the WriteConcern
<T> Iterable<Key<T>>
save(T... entities)
Saves the entities (Objects) and updates the @Id field