-
Jun 6th, 2011, 08:12 PM
#1
Usefulness of MongoTemplate#prepareCollection
I see that in Spring Data Mongo M3, MongoTemplate has a prepareCollection method. Default impl would set slaveOk on it (if requested on the MongoTemplate). From what I grok, the intent is to allow subclasses can do additional settings on the collection.
The problem I see with this is, DBCollection is cached by Mongo Java Driver. It creates one instance per VM for a collection name. So naturally any provisioning done on a DBCollection by multiple threads will behave unpredictably.
I would propose to change the API to say prepareCursor, and use DBCursors for all APIs which are request scoped.
Thoughts/opinions?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules