Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- "timestamp": "2018-07-22T17:06:20.111+0000",
- "status": 500,
- "error": "Internal Server Error",
- "message": "E11000 duplicate key error collection: newdb.user index: subscribedTo.username dup key: { : null }; nested exception is com.mongodb.MongoWriteException: E11000 duplicate key error collection: newdb.user index: subscribedTo.username dup key: { : null }",
- "path": "/user/add"
- }
- @Document(collection = "user")
- @Data
- public class User{
- @Id
- private String id;
- @Indexed(unique = true)
- @NotBlank
- private String username;
- @NotBlank
- @Size(min=5, max=32)
- private String password;
- @Indexed(unique = true)
- @Email
- private String email;
- @CreatedDate
- private Date dateRegistered;
- @LastModifiedDate
- private Date dateLastEntry;
- private String profilePictureUrl;
- private List<User> subscribedTo;
- private int active; //0 for false
- public User(@NotBlank String username,
- @NotBlank @Size(min = 5, max = 32) String password,
- @Email String email,
- String profilePictureUrl) {
- this.id = UUID.randomUUID().toString();
- this.username = username;
- this.password = password;
- this.email = email;
- this.dateRegistered = new Date();
- this.dateLastEntry = new Date();
- this.profilePictureUrl = profilePictureUrl;
- this.subscribedTo = Arrays.asList();
- this.active = 1;
- }
- }
Add Comment
Please, Sign In to add comment