Zubair Zubair - 17 days ago 9
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.

Comments