I have the following abstract class:
public abstract class StandardTimeStamp {
@Temporal(TemporalType.TIMESTAMP)
@Column(nullable = false)
@JsonIgnore
private Date lastUpdated;
@PreUpdate
public void generatelastUpdated() {
this.lastUpdated = new Date();
}
public Date getLastUpdated() {
return lastUpdated;
}
public void setLastUpdated(Date lastUpdated) {
this.lastUpdated = lastUpdated;
}
}
I have an entity that is a subclass in which I need the lastUpdate value to be sent to the browser, so I need to override the @JsonIgnore. I have tried a few things, the following code being one of them:
public class MyEntity extends StandardTimestamp implements Serializable {
@Column(name = "LastUpdated")
private Date lastUpdated;
@JsonIgnore(false)
@Override
public Date getLastUpdated() {
return lastUpdated;
}
}
This does add the lastUpdated attribute on the JSON response, however its value is null when it is not null in the database. I have other Dates in the subclass that work, but they aren't hidden with @IgnoreJson in the super class.
Any thoughts?