I have this code in a class named Project
:
@Transient
public List<Release> getAllReleases() {
List<Release> releases = new ArrayList<Release>();
...
return releases;
}
When a project object is serialized the getAllReleases()
method is called, and an allReleases
field is added to the serialized object.
If I add @JsonIgnore
before the method I get the same result. So I wonder how can I implement a getFoo()
method which is ignored by Jackson when serializing the object.
Alternatively I could do:
static public List<Release> getAllReleases(Project proj) {
List<Release> releases = new ArrayList<Release>();
...
return releases;
}
but the solution looks a bit ugly, and I'm pretty sure there must be some simpler mechanism provided by Jackson.
Am I missing something? TIA