Closed almostimplemented closed 7 years ago
Can you please attach also the entity you are trying to encode / decode? I need more context when this error occurs.
I probably see. You want to have field:
@Id
ObjectId id;
instead of
@Id
String id;
Am I right?
e.g.
@Entity
public class FooEntity {
@Id
String id;
String foo;
}
Decoding data
{ "_id" : { "$oid" : "41b15a4bf3ca1a4ec5371c09" }, "foo" : "bar" }
will try to cast an ObjectId
to a String
. I think your tests won't catch this because you only test decoding things previously encoded, and for all your ID encodings, you use String
type.
Can you please check whether your issue is resolved with the latest commits? I'll release the version if so.
The error is in the
if
block of the following loop inEntityCodec.java
:Why not have the ID field be an
ObjectId
? Seems like that might be preferable anyway.