
Inline adoc files when they are included exactly once. Also fix language tags because this inlining gives us better information on what language the code is written in.
57 lines
1.1 KiB
Plaintext
57 lines
1.1 KiB
Plaintext
== Why is this an issue?
|
|
|
|
Hibernate's lazy loading allows you to retrieve just the data of the current class without being forced to load all its related classes. For instance with lazy loading, you can pull up an instance of a ``++Lecture++`` ``++@Entity++`` without being forced to load all its ``++Student++``s.
|
|
|
|
|
|
But that's only if you're storing the ``++Student++``s in a collection. Store them in an array instead, and the benefits of lazy loading are no longer available.
|
|
|
|
|
|
This rule raises an issue on each array in ``++@Entity++`` classes.
|
|
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source,java]
|
|
----
|
|
@Entity
|
|
public class Lecture {
|
|
|
|
@OneToMany
|
|
private Student [] attendees; // Noncompliant
|
|
// ...
|
|
}
|
|
----
|
|
|
|
|
|
=== Compliant solution
|
|
|
|
[source,java]
|
|
----
|
|
@Entity
|
|
public class Lecture {
|
|
|
|
@OneToMany
|
|
private List<Student> attendees;
|
|
// ...
|
|
}
|
|
----
|
|
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
=== Message
|
|
|
|
Convert this array to a collection.
|
|
|
|
|
|
=== Highlighting
|
|
|
|
* primary: array name
|
|
|
|
|
|
endif::env-github,rspecator-view[]
|