java - Mongojack possible to persist id as string -


Is it possible to type string in IDO field as a Mongo collection in POO?

I have tried to explain the POJO as formally described, but the _id collection property is always maintained as an object id.

Here's my very simple POJO

  public category sticker {@Id @JsonProperty ("_ id") private string ID; The name of the private string; Public string getId () {return ID; } Public Zero Set ID (string id) {this.id = id; } Public string getName () {return name; } Public Zero Setname (string name) {this.name = name; }}  

It depends on whether you have an instance stored in the database Set the id first or not.

If you set it to an arbitrary string, then it will be a string in the database. If you do not set it, then it will be an object id in the database because the Mango DB creates an ID for you.


Comments