Not able to store "_id" as a UUID string in Mongo java

173 Views Asked by At

I am trying to store _id as a String in Mongo, but for some reason, mongo is still overriding and storing it as an ObjectId. Below is my Java class

    public class Subscription {
    @JsonProperty("subscriptionId")
        private String _id;
        private List<FilterAttribute> filterAttributes;
    }

Here is my code that saves the object.

 private final MongoCollection<Subscription> mongoCollection;
 mongoCollection.insertOne(subscription);

I tried a few methods but had no luck

0

There are 0 best solutions below