You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In HH the feedback was raised, that always LazyLoading is not correct,
but depends on the use case.
Therefore, a link describing the differences and an exceptional case for
EAGER was added.
Copy file name to clipboardexpand all lines: modules/ROOT/pages/persistence/jpa.adoc
+4-2
Original file line number
Diff line number
Diff line change
@@ -53,9 +53,11 @@ Byte array will cause problems if BLOBs get large because the entire BLOB is loa
53
53
* Always use link:https://jakarta.ee/specifications/persistence/3.1/apidocs/jakarta.persistence/jakarta/persistence/temporaltype[`TemporalType.TIMESTAMP`] with link:https://jakarta.ee/specifications/persistence/3.1/apidocs/jakarta.persistence/jakarta/persistence/temporal[`@Temporal`].
54
54
* Mixing with other granularities causes problems when comparing one value to another.
55
55
56
-
=== Always use lazy loading
56
+
=== Consider the fetch type of relations
57
57
58
-
Application are strongly advised to always use lazy loading. Always override the default of the relationship annotation by providing link:https://jakarta.ee/specifications/persistence/3.1/apidocs/jakarta.persistence/jakarta/persistence/manytomany#fetch()[`fetch = FetchType.LAZY`], even if this is the default already.
58
+
When creating a relation between entities, the correct fetch type should be always considered for the use case. The difference between the two types eager and lazy loading is described link:https://www.baeldung.com/hibernate-lazy-eager-loading[here].
59
+
Applications are strongly advised to use lazy loading, except it's 100% clear that eager loading is necessary in all cases.
60
+
Always override the default of the relationship annotation by providing the selected link:https://jakarta.ee/specifications/persistence/3.1/apidocs/jakarta.persistence/jakarta/persistence/manytomany#fetch()[FetchType] explicitly, to make it transparent for future developers.
0 commit comments