I've a class like this:
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
}
Why is getter for userBalance getting called when I try to save my newly created User object, and that too multiple times ? I only want it to get called while serializing to json.