【发布时间】:2013-09-27 19:51:59
【问题描述】:
在另一张 SO 海报(Vinicius Miana)解决我的issue 以插入List[DBObject] ...
// Bulk insert all documents
collection.insert(MongoDBList(docs)) // docs is List[DBObject]
现在,我在尝试插入时看到此错误。
java.lang.IllegalArgumentException: BasicBSONList can only work with numeric keys, not: [_id]
编辑
完整的堆栈跟踪
[info] java.lang.IllegalArgumentException: BasicBSONList can only work with numeric keys, not: [_id]
[info] at org.bson.types.BasicBSONList._getInt(BasicBSONList.java:161)
[info] at org.bson.types.BasicBSONList._getInt(BasicBSONList.java:152)
[info] at org.bson.types.BasicBSONList.get(BasicBSONList.java:104)
[info] at com.mongodb.DBCollection.apply(DBCollection.java:767)
[info] at com.mongodb.DBCollection.apply(DBCollection.java:756)
[info] at com.mongodb.DBApiLayer$MyCollection.insert(DBApiLayer.java:220)
[info] at com.mongodb.DBApiLayer$MyCollection.insert(DBApiLayer.java:204)
[info] at com.mongodb.DBCollection.insert(DBCollection.java:76)
[info] at com.mongodb.casbah.MongoCollectionBase$class.insert(MongoCollection.scala:508)
[info] at com.mongodb.casbah.MongoCollection.insert(MongoCollection.scala:866)
我已经检查了 post 与我完全相同的问题,但我不确定如何应用已接受的答案。
此错误是否意味着我无法插入任何键值对,使得 value 不能转换为 Int(根据 BasicBSONList)?
【问题讨论】: