I am trying to upgrade spring-data-mongodb from 1.5 to 2.1.0.M3 so I modified the pom dependency from :
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb</artifactId>
<version>1.5.0.RELEASE</version>
</dependency>
to 2.1.0.M3
here is a sample method that used to work fine with 1.5
@Override
public List<DBObject> getNews() {
DBCollection collection = mongoTemplate.getCollection(DbCollections.news);
DBObject query= getIsDeletedCondition(new BasicDBObject(),
DbColsNews.isDeleted,Boolean.FALSE);
DBCursor myCursor = collection.find(query).sort(new BasicDBObject(DbColsNews.dateAdded,1));
return myCursor.toArray();
}
The error I am getting is :
Type mismatch: cannot convert from MongoCollection<Document> to DBCollection
When I modify the line:
DBCollection collection = mongoTemplate.getCollection(DbCollections.news);
to
MongoCollection<Document> collection = mongoTemplate.getCollection(DbCollections.news);
I get the error
The method find(Class<TResult>) in the type MongoCollection<Document> is not applicable for the arguments (DBObject)
on this line:
DBCursor myCursor = collection.find(query).sort(new BasicDBObject(DbColsNews.dateAdded,1));
what is the correct upgrade procedure for the mongo-java-driver/spring-data-mongodb ?