rspec/rules/S3372/java/rule.adoc

60 lines
1.1 KiB
Plaintext
Raw Normal View History

== Why is this an issue?
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++``.
=== Noncompliant code example
2021-04-28 16:49:39 +02:00
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;
// ...
----
=== Compliant solution
2021-04-28 16:49:39 +02:00
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)
=== Message
Make this class "Serialiazable".
=== Highlighting
class name
'''
== Comments And Links
(visible only on this page)
=== on 1 Dec 2015, 11:14:17 Michael Gumowski wrote:
LGTM!
endif::env-github,rspecator-view[]