Java 如何使用Morphia将对象集合保存到MongoDB?
我目前正在迭代一组对象并逐个保存它们。我想有办法直接保存整个收藏吗Java 如何使用Morphia将对象集合保存到MongoDB?,java,mongodb,morphia,Java,Mongodb,Morphia,我目前正在迭代一组对象并逐个保存它们。我想有办法直接保存整个收藏吗 注意,我以后需要能够从DataStore类的javadoc检索每个单独的对象(而不是整个集合)。。在旧版本上可能不可用。甚至我认为这是一次内部迭代和保存一个,但它可能会得到优化,所以使用它比自己迭代要好 <T> Iterable<Key<T>> save(Iterable<T> entities) Saves the entities (Objects) an
注意,我以后需要能够从DataStore类的javadoc检索每个单独的对象(而不是整个集合)。。在旧版本上可能不可用。甚至我认为这是一次内部迭代和保存一个,但它可能会得到优化,所以使用它比自己迭代要好
<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
Iterable
保存(可编辑实体)
保存实体(对象)并更新@Id字段
可迭代的
保存(Iterable实体,com.mongodb.WriteConcern wc)
保存实体(对象)并使用WriteConcern更新@Id字段
可迭代的
保存(T…实体)
保存实体(对象)并更新@Id字段
)