我有以下收藏“播放器”
{
"_id" : ObjectId("5426efb844ae829d1dcdaa6d"),
"username" : "Foobar",
"password" : "0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33",
"gameIds" : [
"5426f10544ae8502f731d8a0"
]
}
它有一个散列密码。当我尝试将 til 映射回我的 Player 对象时,除了密码之外的所有内容都被映射。密码为空。
这是我的带有映射的播放器
@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<>();
}
我正在像这样保存播放器:
Player player = new Player();
player.setUsername(username);
player.getGameIds().add(pbfId);
player.setPassword(DigestUtils.sha1Hex("foo"));
playerCollection.insert(player);
像这样阅读:
DBCursor<Player> username = playerCollection.find(DBQuery.is("username", "Foobar"), new BasicDBObject());
Player player = username.next();
此处除密码外的所有内容均已正确映射