I have Entity Class with LocalDate in it and Entity Class it-self implements serializable as per the JPA specifications.
Everything is up untill now, but SonarQube now complains the:
Local Date is a Value type Class and should not be serialized.
It suggests to either remove the field or make it transient - both of which wont work in this case as we need those fields to be persisted to the database or maybe some in-memory storage.
public class User implements Serializable{
//other attributes
@Column(name = "UPDATED_DATE")
private LocalDate updatedDate;
}
Could anyone please suggest how can we work around this?
Thanks
As stated in the documentation, https://sonarcloud.io/coding_rules?open=squid%3AS3437&rule_key=squid%3AS3437
You can either put transient
in front of the date
field
or you can suppress the warning like this:
@SuppressWarnings("squid:S3437") //LocalDate is serializable
public class User implements Serializable{..}