This question regarding to Spring boot, Mongo4.0, Spring-data application.
I have upgraded from MongoDB 3.6.x to MongoDB 4.0 and Spring data 2.0.x to Spring-data 2.1.0 for transactional management while inserting data into multiple documents. But here I face this issue while creating a database, collection and inserting a document into the collection.
Cannot create namespace sampledb_200.demo in multi-document transaction
Here sampldb_200 is database name and demo is the collection name.
In earlier mongodb3.6.X versions, Spring Data 2.0.x, I was able to do database, collection creation, document insertion simultaneously even database and collection do not exist.
Using Spring Data 2.1.0, MongoDB 4.0, Database, collection creation, and insertion does not happen under one function and database, collection creation to be done explicitly.
Spring is embracing a new feature shipped with MongoDB 4.0 that supports multi-document transactions. That feature works only for existing collections, ie, a multi-document transaction cannot include an insert operation that would result in the creation of a new collection. You should create your collections before hand to use this feature.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With