@JsonIgnore vs @Transient -difference?

Which one should I use to skip the field for serialization and de-serialization.

@JsonIgnore why should we use it if @Transient also skips a field from serialization and de-serialization process?

+3


source to share


1 answer


The clear difference between the two is that it is @Transient

used as part of JPA to ignore a field from persist if marked as @Transient

.

Where as @JsonIgnore

is only used to ignore the marked field from serialized, de-serialized to and from JSON.



This means that a field marked as @JsonIgnore

can persist in JPA persistence, where as a field marked as @Transient

it will not be saved and will not be serialized, de-serialized.

+10


source







All Articles