I have the following collection "player"
{
"_id" : ObjectId("5426efb844ae829d1dcdaa6d"),
"username" : "Foobar",
"password" : "0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33",
"gameIds" : [
"5426f10544ae8502f731d8a0"
]
}
It has a hashed password. When I try to map til back to my Player object, everything except the password is being mapped. The password is null.
This is my Player with mappings
@Data
@JsonRootName("player")
@NoArgsConstructor
public class Player {
@JsonIgnore
public static final String COL_NAME = "player";
@ObjectId
@Id
private String id;
/**Will use this token to authorize the user. This UUID should be cached once the user logs in */
@JsonIgnore
private UUID token = UUID.randomUUID();
@NotBlank
//Unique
private String username;
@Email
private String email;
@NotBlank
private String password;
/** Set of unique active games * */
private Set<String> gameIds = new HashSet<>();
}
I am saving the player like this:
Player player = new Player();
player.setUsername(username);
player.getGameIds().add(pbfId);
player.setPassword(DigestUtils.sha1Hex("foo"));
playerCollection.insert(player);
And reading like this:
DBCursor<Player> username = playerCollection.find(DBQuery.is("username", "Foobar"), new BasicDBObject());
Player player = username.next();
Here everything except the password is correctly mapped
I don't know what happened, but seems like I queried the wrong database. I have no idea how this happened.
After going against the correct database, it worked fine
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.