我是这样的一个班级:
public class User implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(name = "units")
@Digits(integer = 9, fraction = 2)
@JsonIgnore
private BigDecimal units;
@Transient
private Balance userBalance;
public Balance getUserBalance() {
return new Balance(this);
}
//...Code removed for brevity
}
当我尝试保存新创建的User对象时,为什么会调用getter for userBalance?我只希望在序列化为json时调用它。