diff --git a/CHANGELOG.md b/CHANGELOG.md index 171ab3c4..90f08446 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/README.md b/README.md index e763ae1a..e177eb9b 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/docs/modules/ROOT/pages/features/lazies.adoc b/docs/modules/ROOT/pages/features/lazies.adoc index 80a04834..ba79f922 100644 --- a/docs/modules/ROOT/pages/features/lazies.adoc +++ b/docs/modules/ROOT/pages/features/lazies.adoc @@ -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 +{ +} +---- + +[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 +{ +} +---- + +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.