rspec/rules/S3372/java/rule.adoc

50 lines
1.0 KiB
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
2022-02-04 17:28:24 +01:00
[source,java]
2021-04-28 16:49:39 +02:00
----
@Entity
pubic class Person { // Noncompliant
private String fname;
// ...
----
2021-04-28 16:49:39 +02:00
== Compliant Solution
2022-02-04 17:28:24 +01:00
[source,java]
2021-04-28 16:49:39 +02:00
----
@Entity
pubic class Person implements Serializable {
private String fname;
// ...
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::message.adoc[]
include::highlighting.adoc[]
'''
== Comments And Links
(visible only on this page)
include::comments-and-links.adoc[]
endif::env-github,rspecator-view[]