I have the following piece of code that tries to insert a document object into mongoDB.
return reactiveMongoTemplate.insert(document)
.doOnSuccess(filler -> System.out.println(filler))
.onErrorResume(e -> {
String message = format("Error saving %s", e.getMessage());
log.error(message, e);
throw new PersistenceException(message, e);
})
.block();
When I debug I get an error that says org.springframework.data.mapping.MappingException: Couldn't find PersistentEntity for type class org.bson.Document!
This is identified to be in the first line with the return. Does anyone know why this is happening?
This seems to be a bug (at least it is similar to this reported issue ). Anyway, it seems the insert method that includes the collection name as the second parameter does work correctly:
return reactiveMongoTemplate.insert(document, "documentCollection")
// ...
That worked for me.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.