EntityClass中的LocalDate使sonarQube烦恼

时间:2018-12-07 20:37:33

标签: java jpa java-8 sonarqube localdate

我有一个带有LocalDate的实体类,并且它自己根据JPA规范实现了可序列化的实体类。

一切都到现在为止,但是SonarQube现在抱怨:

Local Date is a Value type Class and should not be serialized.

它建议删除该字段或使其成为临时字段-在这种情况下,这两种方法都不起作用,因为我们需要将这些字段保留到数据库或某些内存中。

public class User implements Serializable{
    //other attributes

    @Column(name = "UPDATED_DATE")
    private LocalDate updatedDate;

}

谁能建议我们如何解决这个问题?

谢谢

1 个答案:

答案 0 :(得分:0)

如文档中所述, https://sonarcloud.io/coding_rules?open=squid%3AS3437&rule_key=squid%3AS3437

您可以将transient放在date字段的前面 或者您可以像这样抑制警告:

@SuppressWarnings("squid:S3437") //LocalDate is serializable
public class User implements Serializable{..}