0

I am using Mongodb Java driver. My Mongodb version is 3.4.2 and MongoDB Java driver version 3.4.2. I am using Spring Data Release Train Ingalls (I think this is the latest version).

I see that the Spring Data MongoOperations class uses DBCOllection, DBObject classes in it's API. Referring to another answer on SO, I see that its recommended that we shouldn't be using DBCollection and other similar classes going forward and instead use MongoCollection etc. (This answer is by Driver's author himself)

MongoCollection versus DBCollection java

As a result, I am very confused now whether should I be using MongoCollection class directly or Spring data classes like MongoOperations ( Spring Data has lot of other helper classes for deserializing/serializing etc) Some of the features like projections are not available on old classes like DBCollection.

Can anyone please help? What is the recommended approach, should I be using Spring Data's classes like MongoOperations or MongoCollection etc.

Regards, V

Community
  • 1
  • 1
LearnToLive
  • 462
  • 9
  • 25

1 Answers1

1

The current release 1.10.0 doesn't have support for Mongo 3.x classes.

The upcoming spring 2.0.0 release has support for 3.x classes. So you can use all the newer classes with MongoOperations

http://docs.spring.io/spring-data/data-mongo/docs/2.0.0.M1/reference/html/#new-features.2-0-0

s7vr
  • 73,656
  • 11
  • 106
  • 127
  • Thanks. That's makes sense. I did check the link provided. Looks like post release of version 2.0.0 I should have what I am after. – LearnToLive Feb 19 '17 at 18:01