Skip to content

Commit

Permalink
Added lazy documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
JohannesRabauer committed Dec 9, 2024
1 parent 2eedf70 commit c94f087
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

* Updated org.springframework.boot.version to v3.4.0
* Updated EclipseStore to v2.0.0
* Implemented Lazy Repositories with ``LazyEclipseStoreRepository``

# 2.3.1

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ the [demos](./spring-data-eclipse-store-demo):

* [Simple demo](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/simple)
* [Complex demo](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)
* [Lazy demo](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/lazy)
* [Demo with coexisting JPA](https://github.com/xdev-software/spring-data-eclipse-store/tree/develop/spring-data-eclipse-store-jpa/src/main/java/software/xdev/spring/data/eclipse/store/jpa)
* [Dual storage demo](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/dual/storage)

Expand Down
28 changes: 28 additions & 0 deletions docs/modules/ROOT/pages/features/lazies.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,34 @@ public class Owner extends Person
//...
----

== Repositories

Entities in a repository are by default **not lazy**.
But we made it as easy as possible for you to make these entities lazy: Instead of extending the ``EclipseStoreRepository`` (or any similar class from the ``software.xdev.spring.data.eclipse.store.repository.interfaces``-Package), you simply extend the ``LazyEclipseStoreRepository``.

=== 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/lazy/CustomerRepository.java[Example from lazy demo]

[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/simple/CustomerRepository.java[Before (not lazy)]"]
----
public interface CustomerRepository extends CrudRepository<Customer, String>
{
}
----

[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/lazy/CustomerRepository.java[After (lazy)]"]
----
public interface CustomerRepository extends LazyEclipseStoreCrudRepository<Customer, String>
{
}
----

Every instance of the ``Customer``-Entities are now wrapped in a https://docs.eclipsestore.io/manual/storage/loading-data/lazy-loading/index.html[``Lazy``-Reference].
That means that these objects are **only loaded from the storage, if they are needed** e.g. when ``findAll`` is called.

The method **``findById`` only loads the entities with the corresponding IDs**, because a separate list with all ids is stored.
But if any method like **``findByName`` or ``findByChild`` is used, all objects are loaded** from the storage.
This is currently the only way to get the actual values of the entities.

== Internals

SpringDataEclipseStoreLazies work as a proxy for the EclipseStore-Lazies.
Expand Down

0 comments on commit c94f087

Please sign in to comment.