I'm trying to create mongo objects with auto-increment string object ids that look like this (to be backwards compatible with previous jongo versions):
{
"_id" : "55b69cd314b811a73c2f65f5"
}
I've tried every combination of @MongoId, @MongoObjectId, and variable names and still can't get it to insert as an auto-increment object id string. It always ends up looking like this:
{
"_id" : ObjectId("55b69cd314b811a73c2f65f5")
}
public static class Friend {
@MongoId
@MongoObjectId
private String key;
}
Friend friend = new Friend();
getJongoFileCollection()
.withWriteConcern(WriteConcern.SAFE)
.insert(friend);
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>3.0.3</version>
</dependency>
<dependency>
<groupId>org.jongo</groupId>
<artifactId>jongo</artifactId>
<version>1.2</version>
</dependency>
Mongo Server version: 2.4.9
What do I need to do to insert documents with string _id fields that are auto-created?