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
private final Lazy<List<Pet>> pets = SpringDataEclipseStoreLazy.build(new ArrayList<>());
31
30
//...
32
31
----
33
32
33
+
== FetchType.LAZY
34
+
35
+
In Spring JPA, lazy loading is achieved by annotating a field or property with ``FetchType.LAZY``.
36
+
This approach leverages JPA's built-in mechanisms to defer the retrieval of the related entity until it is accessed.
37
+
38
+
In contrast, {product-name} takes a different approach.
39
+
Instead of using annotations, you wrap the object intended to be loaded lazily in a ``Lazy``-wrapper.
40
+
This wrapper encapsulates the object and ensures it is only loaded when needed.
41
+
42
+
[source,java,title="JPA Example with lazy"]
43
+
----
44
+
import jakarta.persistence.OneToMany;
45
+
46
+
public class Owner extends Person
47
+
{
48
+
@OneToMany(fetch = FetchType.LAZY)
49
+
private final List<Pet> pets = new ArrayList<>();
50
+
//...
51
+
----
52
+
53
+
[source,java,title="https://github.com/xdev-software/spring-data-eclipse-store/tree/develop/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/complex/owner/Owner.java[Slightly changed example from complex demo]"]
private final List<Lazy<Pet>> pets = new ArrayList<>();
62
+
//...
63
+
----
64
+
65
+
The ``Lazy``-wrapper makes lazy loading **explicit and flexible**, avoiding JPA-specific overhead and potential exceptions.
66
+
But it introduces a custom, less-standardized approach that may increase boilerplate and requires developers to remember to use the wrapper, which could lead to errors if overlooked.
67
+
34
68
== Repositories
35
69
36
70
Entities in a repository are by default **not lazy**.
Copy file name to clipboardExpand all lines: docs/modules/ROOT/pages/known-issues.adoc
+34Lines changed: 34 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,3 +29,37 @@ This **should** handle most problems with the ClassLoader.
29
29
Restarting the storage leads to a reloading of all entities and may take some time, yet circumvents the Restart ClassLoader Issue.
30
30
31
31
The behavior can be configured through xref:configuration.adoc#context-close-shutdown-storage[Properties] and is implemented in the https://github.com/xdev-software/spring-data-eclipse-store/tree/develop/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/config/EclipseStoreClientConfiguration.java[EclipseStoreClientConfiguration.java].
32
+
33
+
== Multiple Repositories with related entities [[multi-repos-with-related-entities]]
34
+
35
+
In SQL databases, relationships between entities are explicitly defined and enforced by the database system.
36
+
This ensures that constraints, such as foreign keys, are consistently maintained.
37
+
38
+
In contrast, relationships in a Java object graph are solely defined by the developer.
39
+
If an object within the graph does not maintain a reference back to its parent or containing object, it has no inherent knowledge of that relationship.
40
+
Consequently, finding such a relationship requires searching the entire object graph, which can be highly inefficient.
41
+
42
+
image::DependingClasses.svg[Example structure with orders and articles]
43
+
44
+
Example Scenario:
45
+
Consider an *order object* that contains references to several *article objects*.
46
+
In this case, determining which order contains a specific article is nearly impossible without traversing the entire object graph to locate it.
47
+
This lack of direct reference contrasts sharply with the behavior of SQL databases.
48
+
49
+
What Happens When an Article is Deleted?
50
+
51
+
1. In an *SQL Database*: +
52
+
Attempting to delete an article that is still referenced (e.g., by an order) would typically result in an exception. +
53
+
The database enforces referential integrity, preventing the deletion of a referenced entity.
54
+
55
+
2. In *{product-name}*: +
56
+
Deleting an article from the article repository is allowed, even if it is still referenced elsewhere. +
57
+
The system does not track or enforce such references.
58
+
As a result:
59
+
60
+
* The article is removed from the repository.
61
+
* However, the order still retains its reference to the now-deleted article.
62
+
* If the order is subsequently saved, the article is reintroduced into the repository.
63
+
64
+
This behavior is fundamentally different from the strict relationship management seen in SQL databases.
65
+
Developers must be aware of these differences to avoid unintended side effects in their applications.
Copy file name to clipboardExpand all lines: spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/EclipseStoreStorage.java
Copy file name to clipboardExpand all lines: spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/reposyncer/SimpleRepositorySynchronizer.java
+4-1Lines changed: 4 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -50,7 +50,7 @@ public SimpleRepositorySynchronizer(final RootDataV2_4 root)
Copy file name to clipboardExpand all lines: spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/deletion/DeletionTest.java
0 commit comments