spring-data-mongodb icon indicating copy to clipboard operation
spring-data-mongodb copied to clipboard

Spring Data Mongo fails while converting the Document to Object type

Open logztechstuff opened this issue 3 years ago • 3 comments

We have a POJO class that contains the Map with key type as String and value type as Object (Map<String, Object>). Until version 3.1, the Document from DB is converted properly to Map<String, Object>. Once we upgraded to 3.2, the conversion is failing with an error,

org.springframework.data.mapping.MappingException: Expected to read Document Document{} into type class java.lang.Object but didn't find a PersistentEntity for the latter!

The read method of MappingMongoConvertor had a statement, if (typeToUse.equals(ClassTypeInformation.OBJECT)) { return (S) bson; }

But the above code is not available in the latest versions of the MappingMongoConvertor.

Please help us with how to solve this problem.

Thanks in advance.

logztechstuff avatar Sep 12 '22 18:09 logztechstuff

If you'd like us to spend some time investigating, please take the time to provide a complete minimal sample (something that we can unzip or git clone, build, and deploy) that reproduces the problem.

christophstrobl avatar Sep 13 '22 05:09 christophstrobl

Hi @christophstrobl Thanks for the response. Ours is a very large project, so didn't share the sample. I will work on a small project with a similar use case and share it. Thanks again.

logztechstuff avatar Sep 13 '22 06:09 logztechstuff

See also https://stackoverflow.com/questions/73689924/spring-data-mongo-conversion-is-not-working-for-object-type-since-version-3-2

mp911de avatar Sep 13 '22 12:09 mp911de

Closing this one because we cannot reproduce the issue.

christophstrobl avatar Mar 09 '23 10:03 christophstrobl