Use Mongo createIndex instead of deprecated ensureIndex.
This commit is contained in:
Jan Bartel 2016-06-15 13:12:37 +10:00
parent 3deebad503
commit 297918f719
1 changed files with 17 additions and 6 deletions

View File

@ -175,12 +175,23 @@ public class MongoSessionIdManager extends AbstractSessionIdManager
_server = server; _server = server;
_sessions = sessions; _sessions = sessions;
_sessions.ensureIndex( DBObject idKey = BasicDBObjectBuilder.start().add("id", 1).get();
BasicDBObjectBuilder.start().add("id",1).get(), _sessions.createIndex(idKey,
BasicDBObjectBuilder.start().add("unique",true).add("sparse",false).get()); BasicDBObjectBuilder.start()
_sessions.ensureIndex( .add("name", "id_1")
BasicDBObjectBuilder.start().add("id",1).add("version",1).get(), .add("ns", _sessions.getFullName())
BasicDBObjectBuilder.start().add("unique",true).add("sparse",false).get()); .add("sparse", false)
.add("unique", true)
.get());
DBObject versionKey = BasicDBObjectBuilder.start().add("id", 1).add("version", 1).get();
_sessions.createIndex(versionKey, BasicDBObjectBuilder.start()
.add("name", "id_1_version_1")
.add("ns", _sessions.getFullName())
.add("sparse", false)
.add("unique", true)
.get());
} }