Zubair Zubair - 7 months ago 53
Java Question

MongoDb stores Float field as Double. Getting IllegalArgumentException

Data is stored correctly, however when I get the data back from Mongodb, I get the


IllegalArgumentException. cannot set java.lang.Float to java.lang.Double.


Does it have any converters, which will convert automatically from
double
to
float
.

Answer

You need to deserialize the object, and assign to the lowest leaf of the tree. and then use the converter to convert from double to float and vice versa.