-
Type:
Task
-
Resolution: Done
-
Priority:
Critical - P2
-
None
-
Affects Version/s: 3.8.1
-
Component/s: API
-
None
-
Environment:mac
-
None
-
None
-
None
-
None
-
None
-
None
-
None
I have a very simple POJO - where I don't have an _id field ( I let mongo generate the _id field for me ).
I am able to insert / update and delete successfully. But when i try to list out all the POJO instances in my collection
package com.mongodb.reactivestreams.client; /** * The MongoCollection interface. * * <p>Note: Additions to this interface will not be considered to break binary compatibility.</p> * * @param <TDocument> The type that this collection will encode documents from and decode documents to. * @since 1.0 */ @ThreadSafe public interface MongoCollection<TDocument> { /** * Finds all documents in the collection. * * @return the fluent find interface * @mongodb.driver.manual tutorial/query-documents/ Find */ FindPublisher<TDocument> find();
I get the following error -
We are using mongodb-driver-reactivestreams (1.9.0)
{{}}
org.bson.codecs.configuration.CodecConfigurationException: An exception occurred when decoding using the AutomaticPojoCodec. Decoding into a 'FooBar' failed with the following exception: Failed to decode 'FooBar'. Decoding '_id' errored with: readString can only be called when CurrentBSONType is STRING, not when CurrentBSONType is OBJECT_ID. A custom Codec or PojoCodec may need to be explicitly configured and registered to handle this type. at org.bson.codecs.pojo.AutomaticPojoCodec.decode(AutomaticPojoCodec.java:40) ~[bson-3.7.1.jar:?] at com.mongodb.operation.CommandResultArrayCodec.decode(CommandResultArrayCodec.java:52) ~[mongodb-driver-core-3.8.0.jar:?] at com.mongodb.operation.CommandResultDocumentCodec.readValue(CommandResultDocumentCodec.java:60) ~[mongodb-driver-core-3.8.0.jar:?] at org.bson.codecs.BsonDocumentCodec.decode(BsonDocumentCodec.java:84) ~[bson-3.7.1.jar:?] at org.bson.codecs.BsonDocumentCodec.decode(BsonDocumentCodec.java:41) ~[bson-3.7.1.jar:?] at org.bson.codecs.configuration.LazyCodec.decode(LazyCodec.java:47) ~[bson-3.7.1.jar:?] at org.bson.codecs.BsonDocumentCodec.readValue(BsonDocumentCodec.java:101) ~[bson-3.7.1.jar:?] at com.mongodb.operation.CommandResultDocumentCodec.readValue(CommandResultDocumentCodec.java:63) ~[mongodb-driver-core-3.8.0.jar:?] at org.bson.codecs.BsonDocumentCodec.decode(BsonDocumentCodec.java:84) ~[bson-3.7.1.jar:?] at Caused by: org.bson.codecs.configuration.CodecConfigurationException: Failed to decode 'FooBar'. Decoding '_id' errored with: readString can only be called when CurrentBSONType is STRING, not when CurrentBSONType is OBJECT_ID. at org.bson.codecs.pojo.PojoCodecImpl.decodePropertyModel(PojoCodecImpl.java:195) ~[bson-3.7.1.jar:?] at org.bson.codecs.pojo.PojoCodecImpl.decodeProperties(PojoCodecImpl.java:173) ~[bson-3.7.1.jar:?] at org.bson.codecs.pojo.PojoCodecImpl.decode(PojoCodecImpl.java:127) ~[bson-3.7.1.jar:?] at org.bson.codecs.pojo.PojoCodecImpl.decode(PojoCodecImpl.java:131) ~[bson-3.7.1.jar:?] at org.bson.codecs.pojo.AutomaticPojoCodec.decode(AutomaticPojoCodec.java:37) ~[bson-3.7.1.jar:?] ... 46 more Caused by: org.bson.BsonInvalidOperationException: readString can only be called when CurrentBSONType is STRING, not when CurrentBSONType is OBJECT_ID. at org.bson.AbstractBsonReader.verifyBSONType(AbstractBsonReader.java:690) ~[bson-3.7.1.jar:?] at org.bson.AbstractBsonReader.checkPreconditions(AbstractBsonReader.java:722) ~[bson-3.7.1.jar:?] at org.bson.AbstractBsonReader.readString(AbstractBsonReader.java:457) ~[bson-3.7.1.jar:?] at org.bson.codecs.StringCodec.decode(StringCodec.java:39) ~[bson-3.7.1.jar:?] at org.bson.codecs.StringCodec.decode(StringCodec.java:28) ~[bson-3.7.1.jar:?] at org.bson.codecs.DecoderContext.decodeWithChildContext(DecoderContext.java:93) ~[bson-3.7.1.jar:?] at org.bson.codecs.pojo.PojoCodecImpl.decodePropertyModel(PojoCodecImpl.java:189) ~[bson-3.7.1.jar:?] at org.bson.codecs.pojo.PojoCodecImpl.decodeProperties(PojoCodecImpl.java:173) ~[bson-3.7.1.jar:?] at org.bson.codecs.pojo.PojoCodecImpl.decode(PojoCodecImpl.java:127) ~[bson-3.7.1.jar:?] at org.bson.codecs.pojo.PojoCodecImpl.decode(PojoCodecImpl.java:131) ~[bson-3.7.1.jar:?] at org.bson.codecs.pojo.AutomaticPojoCodec.decode(AutomaticPojoCodec.java:37) ~[bson-3.7.1.jar:?] ... 46 more