【问题标题】:Jackson, hashed password not being mapped杰克逊,未映射散列密码
【发布时间】:2014-11-22 12:11:57
【问题描述】:

我有以下收藏“玩家”

{
    "_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();

这里除了密码之外的所有东西都正确映射了

【问题讨论】:

  • 杰克逊在哪里参与?
  • Mongojack 在内部使用它

标签: java mongodb jackson mongo-jackson-mapper mongojack


【解决方案1】:

我不知道发生了什么,但好像我查询了错误的数据库。我不知道这是怎么发生的。

在针对正确的数据库后,它工作正常

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-11-19
    • 2013-04-11
    • 1970-01-01
    • 2011-10-22
    • 2012-10-01
    • 1970-01-01
    • 2014-10-10
    • 2015-01-09
    相关资源
    最近更新 更多