rspec/rules/S3372/java/rule.adoc

39 lines
901 B
Plaintext

The Java Persistence API specification imposes only a conditional requirement that ``++@Entity++`` classes be ``++Serializable++``:
____
If an entity instance is to be passed by value as a detached object (e.g., through a remote interface), the entity class must implement the ``++Serializable++`` interface.
____
But it's best practice to make all such classes ``++Serializable++`` from the start. So this rule raises an issue when an ``++@Entity++`` does not implement ``++Serializable++``.
== Noncompliant Code Example
----
@Entity
pubic class Person { // Noncompliant
private String fname;
// ...
----
== Compliant Solution
----
@Entity
pubic class Person implements Serializable {
private String fname;
// ...
----
ifdef::env-github,rspecator-view[]
'''
== Comments And Links
(visible only on this page)
include::comments-and-links.adoc[]
endif::env-github,rspecator-view[]