Auto Increment _Id in Spring MongoRepository

1.6k Views Asked by At

Is there a way to mimic the @GeneratedValue in MongoRepository?

I would like to auto increment the _id

1

There are 1 best solutions below

0
On

Not reliably, particularly since MongoDB doesn't support transactions. The recommended approach is to use a MongoDB ObjectID.