7

I have a domain class Loan.java with a field which is not persisted:

@JsonInclude()
@Transient
private LoanRating loanRating;

/* (Public) Getters and setters for that field are available as well */

However, the field does not get serialized - I don't see it on Frontend. I'm doing the serialization with Jackson.

Any ideas what I'm doing wrong?

If you need more information, please tell me and I'll post additional code :)

dave0688
  • 5,372
  • 7
  • 33
  • 64

2 Answers2

9

Thanks for your answers! The comment of @Abdullah Khan pointed me to the correct (and probably easiest) solution.

I solved it with adding the @JsonSerialize annotation:

@Transient
@JsonSerialize
private LoanRating loanRating;

Thanks all for your help :)

dave0688
  • 5,372
  • 7
  • 33
  • 64
3

You can simply define a getter with an JsonProperty annotation like this :

@JsonProperty("LoanRating")
public String getLoanRatingSer() {
    return this.loanRating;
}
jpmottin
  • 2,717
  • 28
  • 25