This is the error which I'm getting java.lang.ClassCastException: java.lang.Integer cannot be cast to com.mongodb.DBObject
Here's my POJO
@Entity("cars")
@Getter
@Setter
public class Car {
@Id
private ObjectId id;
private String defaultChoice;
private Object input;
}
I was able to save this in the cars collection in mongo using morphia with json as
{
"defaultChoice": "sampleChoice",
"input": 432
}
In mongo, the field input is saved with type int32
The exception happens when I try to retrieve the data using morphia. It is not able to map/deserialize the field with Object as type. I tried by changing it to Integer input
. And it worked. I want to try keep this field as Object if possible
Is there a way to fix this ? May be write a custom mapper ?