I am using the example provided in Sessions & Transactions :: Spring Data MongoDB
ClientSession support section.
Assuming the template refer to MongoTemplate
Code compile but fail in action.findOne() with an error
java.lang.IllegalStateException: state should be: ClientSession from same MongoClient
at com.mongodb.assertions.Assertions.isTrue(Assertions.java:109)
at com.mongodb.client.internal.MongoClientDelegate$DelegateOperationExecutor.getClientSession(MongoClientDelegate.java:243)
at com.mongodb.client.internal.MongoClientDelegate$DelegateOperationExecutor.execute(MongoClientDelegate.java:169)
at com.mongodb.client.internal.MongoCollectionImpl.executeSingleWriteRequest(MongoCollectionImpl.java:1085)
at com.mongodb.client.internal.MongoCollectionImpl.executeDelete(MongoCollectionImpl.java:1058)
at com.mongodb.client.internal.MongoCollectionImpl.deleteMany(MongoCollectionImpl.java:548)
at com.mongodb.client.internal.MongoCollectionImpl.deleteMany(MongoCollectionImpl.java:542)
Do not know why it is failing. Any suggestion