Hi All,
I am using the spring-data-mongodb-4.2.1 library and have created a repository using the MongoRepository.class.
I attempted to save data to a collection using the repository.save(obj) method, which was called inside a method annotated with @Transactional. Occasionally,
I encounter the error ‘writeConcern is not allowed within a multi-statement transaction’. This issue is intermittent and difficult to reproduce. Interestingly, the save operation succeeds if I call the API a second time.
Do you have any suggestion?
I wonder if it’s the same root cause as writeConcern is not allowed within a multi-statement transaction, though in that case I don’t think it was intermittent.
What version of the server are you connected to?
Otherwise, it could be an issue in Spring Data MongoDB, perhaps similar to this bug in Mongoose, or in the MongoDB Java driver itself. Which version of the Java driver are you using?
Regards,
Jeff
Hi Jeff,
Thank for quick response.
I am check by using db.version() and result is 5.0.28.
And in my java project using spring-data-mongodb-4.2.1
what should I do?
Thank you.