RestController我在我的應用程序中寫了一個SpringBoot。MongoDB我也在用a 。這是我的實體:public class LocationEntity { @Id private String id; private String name; @DBRef(lazy = true) @JsonIgnore private UserEntity owner; private String description; @DBRef(lazy = true) private List<RoleEntity> roles; private Date date; public LocationEntity(String name, UserEntity owner, String description, List<RoleEntity> roles, Date date) { this.name = name; this.owner = owner; this.description = description; this.roles = roles; this.date = date; }}RoleEntity和UserEntity也是來自同一數據庫的實體。我RestController的方法返回ResponseEntity,所以默認情況下Jackson是用內部來序列化Object的JSON。我想問一下延遲加載的具體情況。如果我使用@JsonIgnorefromJackson忽略序列化中的該字段,ORM 不會從數據庫獲取“惰性字段”嗎?提前感謝您的幫助!
1 回答

江戶川亂折騰
TA貢獻1851條經驗 獲得超5個贊
ORM 只會在需要時獲取那些延遲加載的字段。這意味著如果您指示 Jackson 在序列化期間忽略它們(使用@JsonIgnore
注釋),ORM 將不會獲取它們。
添加回答
舉報
0/150
提交
取消