rspec/rules/S3372/java/rule.adoc

31 lines
740 B
Plaintext
Raw Normal View History

2021-04-28 16:49:39 +02:00
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++``.
2021-04-28 16:49:39 +02:00
== Noncompliant Code Example
----
@Entity
pubic class Person { // Noncompliant
private String fname;
// ...
----
2021-04-28 16:49:39 +02:00
== Compliant Solution
----
@Entity
pubic class Person implements Serializable {
private String fname;
// ...
----