As a relational database provides an auto-increment to the id for entity
. I wonder could we do the same or create another UID
specifically for that entity. For example, I have a User entity, which using Mongo driver POJO and wants to have the userId
auto-increment it, but ones advised that is not safe to do as would break the Object ID. So, if I want to use it, how can I use and show each userId with 1...N?
public class User {
private ObjectId id;
@BsonProperty(value = "userId")
private Long userId;
private String email;
private String fullName;
// private String lastName;
private String password;
// getter & setter
}