java - SpringBoot MongoDB 继承 CreatedDate 和 LastModifiedDate 变为 null
问题描述
我有一个在所有模型中通用的字段的基类
@Getter
@Setter
public class BaseModel {
@Id
private String id;
@CreatedDate
private Date createdAt;
@LastModifiedDate
private Date modifiedAt;
@Version
private Long version;
}
和其他模型正在继承这个类,例如
@Document(collection = "accounts")
@Getter
@Setter
@ToString
public class Account extends BaseModel {
@Indexed(unique = true)
private String name;
}
当我持久化帐户对象时,我可以看到 createdAt 和 modifiedAt 被持久化,但是当我查询同一个帐户对象时,我得到 createdAt 和 modifiedAt 为空。我也启用了 mongo 审计。我也尝试过 TypeAlias 但没有工作,任何建议或帮助将不胜感激
解决方案
推荐阅读
- unit-testing - 数据库单元测试 - 如何模拟过程中的时间
- python - 在熊猫中跟踪具体的时间段
- python - 在文本文件中搜索变量,获取数据并为其分配一个变量(python)
- python - 在我冻结游戏之前,第二个表面不会出现在屏幕上
- c++ - 如何将 TrieNodes 子节点的所有元素初始化为 null
- c# - 不同子属性的通用位置
- java - 在 Maven 项目中的 pom.xml 中找不到依赖项错误
- swashbuckle.aspnetcore - Swagger5.0 更新不使用 Swashbuckle.AspNetCore.Swagger 指令引发构建错误
- java - Java Doc -overview 选项(使用 Eclipse)
- wordpress - Divi 侧边栏工作正常 博客上的主页问题