java - 从 mongo 中检索,在模型(java)中具有新字段但在 DB 中的旧数据中没有,无法解码
问题描述
以前的 java 对象:
@Value
@Wither
@Builder(toBuilder = true)
@NoArgsConstructor(force = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class person {
String id;
// @BsonIgnore
String username;
// @BsonIgnore
String fullName;
@BsonCreator
public DataDomainOwner(
@BsonProperty("id") final String id,
@BsonProperty("username") final String username,
@BsonProperty("fullName") final String fullName
) {
this.id = id;
this.username = username;
this.fullName = fullName;
}
}
新模型是:
@Value
@Wither
@Builder(toBuilder = true)
@NoArgsConstructor(force = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class person {
String id;
// @BsonIgnore
String username;
// @BsonIgnore
String fullName;
boolean acting;
@BsonCreator
public DataDomainOwner(
@BsonProperty("id") final String id,
@BsonProperty("username") final String username,
@BsonProperty("fullName") final String fullName,
@BsonProperty("status") final boolean status
) {
this.iId = id;
this.username = username;
this.fullName = fullName;
this.status = status;
}
}
有人可以帮忙吗?
解决方案
推荐阅读
- python - ValueError:为列找到重复的特征列名称:
- python-3.x - 如何将数学公式转换为 python 代码?
- python - 通过键盘快捷键在vscode中运行python?
- javascript - 为什么我的 && 语句在我制作的这款格斗游戏中不起作用?
- php - ACF字段条件逻辑的foreach数组?
- git - 可以在 Cygwin 中使用 MinGW 版本的 git 吗?
- jquery - 如何使用 Jquery 在 Web 应用程序上继续运行 setInterval
- javascript - fs.createReadStream 不是函数
- angular - 请问如何仅在 Angular 中重新加载后才加载我的第一个选项卡的内容
- java - 尝试在空对象引用上调用虚拟方法“int com.android.server.AlarmManagerService$Batch.size()”