Replies: 2 comments 2 replies
-
org.bson.codecs.configuration.CodecConfigurationException: Failed to decode 'Animal'. Decoding errored with: A class could not be found for the discriminator: 'Cat'. |
Beta Was this translation helpful? Give feedback.
-
I lost track of this over the holiday. Where do things stand now? |
Beta Was this translation helpful? Give feedback.
-
We are facing one issue with upgrading morphia from
The issue is that in the new morphia we have one param _t which is termed as discriminator and using this morphia is able to deserialize any mongo object to java object.
Now in my scenario we are having one class which is being inharited by multiple other classess. (An abstract class can also be used here). The issue is that earlier we used to have custom JsonDeserializer which are not working with the current version of morphia. And since there is so huge data in our database we don't want to do a backfill. Is there a way of writing some custom JsonDeserializer so that older data can be read using new morphia.
Also there is one more problem. When I'm trying to call this controller (Since now custom JsonDeserializer doesn't work with morphia I've removed them) the object gets converted to parant class due to which we are losing some data. Ideally we should recieve the object of child class.
An example of my case is:
Now If I send object of Dog from api its param bark gets lost. Also morphia is able to read all the data for all the newly created documents;
I'm expecting that my Dao layer should be able to read all the data new and old which is already there in DB. Also while making an api call to my service object recieved in my class should be correctly deserialized.
Beta Was this translation helpful? Give feedback.
All reactions