我有一个实体,其中有四个@OneToOne
映射到同一个实体:
@Entity
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id", scope = TaxTable.class)
public class TaxTable extends BaseEntity {
@OneToOne( fetch = FetchType.LAZY)
@JsonView({Views.Summary.class, Views.Detailed.class})
private TaxRate taxRate1;
@OneToOne(fetch = FetchType.LAZY)
@JsonView({Views.Summary.class, Views.Detailed.class})
private TaxRate taxRate2;
@OneToOne(fetch = FetchType.LAZY)
@JsonView({Views.Summary.class, Views.Detailed.class})
private TaxRate taxRate3;
@OneToOne(fetch = FetchType.LAZY)
@JsonView({Views.Summary.class, Views.Detailed.class})
private TaxRate taxRate4;
}
当我从控制器中检索TaxTable时,我得到以下内容:
{
"id": 1,
"taxRate1": {
"id": 1,
// more properties here
},
"taxRate2": 1,
"taxRate3": 1,
"taxRate4": 1
}
这种情况正在发生,因为它们都引用了同一个对象。但有没有办法告诉杰克逊不要这么高效?我正在查看SerlizationFeature,但无法找到有关此内容的任何内容。