diff --git a/.config/pmd/ruleset.xml b/.config/pmd/ruleset.xml
index 667f74e5..7a03f17c 100644
--- a/.config/pmd/ruleset.xml
+++ b/.config/pmd/ruleset.xml
@@ -151,5 +151,12 @@
+
+
+
+
+
+
+
diff --git a/.github/workflows/broken-links.yml b/.github/workflows/broken-links.yml
index c17c3978..8f98f1ad 100644
--- a/.github/workflows/broken-links.yml
+++ b/.github/workflows/broken-links.yml
@@ -11,6 +11,7 @@ permissions:
jobs:
link-checker:
runs-on: ubuntu-latest
+ timeout-minutes: 15
steps:
- uses: actions/checkout@v4
@@ -19,6 +20,8 @@ jobs:
- name: Link Checker
id: lychee
uses: lycheeverse/lychee-action@v2
+ with:
+ fail: false # Don't fail on broken links, create an issue instead
- name: Find already existing issue
id: find-issue
diff --git a/.github/workflows/check-build.yml b/.github/workflows/check-build.yml
index 24130cd2..33f70104 100644
--- a/.github/workflows/check-build.yml
+++ b/.github/workflows/check-build.yml
@@ -26,6 +26,7 @@ env:
jobs:
build:
runs-on: ubuntu-latest
+ timeout-minutes: 30
strategy:
matrix:
@@ -73,6 +74,7 @@ jobs:
checkstyle:
runs-on: ubuntu-latest
if: ${{ github.event_name != 'pull_request' || !startsWith(github.head_ref, 'renovate/') }}
+ timeout-minutes: 15
strategy:
matrix:
@@ -95,6 +97,7 @@ jobs:
pmd:
runs-on: ubuntu-latest
if: ${{ github.event_name != 'pull_request' || !startsWith(github.head_ref, 'renovate/') }}
+ timeout-minutes: 15
strategy:
matrix:
@@ -114,9 +117,6 @@ jobs:
- name: Run PMD
run: ./mvnw -B test pmd:aggregate-pmd-no-fork pmd:check -P pmd -DskipTests -T2C
- - name: Run CPD (Copy Paste Detector)
- run: ./mvnw -B pmd:aggregate-cpd pmd:cpd-check -P pmd -DskipTests -T2C
-
- name: Upload report
if: always()
uses: actions/upload-artifact@v4
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 0bf3805c..236c0f59 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -14,6 +14,7 @@ permissions:
jobs:
check-code:
runs-on: ubuntu-latest
+ timeout-minutes: 30
steps:
- uses: actions/checkout@v4
@@ -48,6 +49,7 @@ jobs:
prepare-release:
runs-on: ubuntu-latest
needs: [check-code]
+ timeout-minutes: 10
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
@@ -109,6 +111,7 @@ jobs:
publish-maven:
runs-on: ubuntu-latest
needs: [prepare-release]
+ timeout-minutes: 60
steps:
- uses: actions/checkout@v4
@@ -140,6 +143,7 @@ jobs:
publish-pages:
runs-on: ubuntu-latest
needs: [prepare-release]
+ timeout-minutes: 15
steps:
- uses: actions/checkout@v4
@@ -169,6 +173,7 @@ jobs:
after-release:
runs-on: ubuntu-latest
needs: [publish-maven]
+ timeout-minutes: 10
steps:
- uses: actions/checkout@v4
diff --git a/.github/workflows/sonar.yml b/.github/workflows/sonar.yml
index b38f0d82..df6dbb7e 100644
--- a/.github/workflows/sonar.yml
+++ b/.github/workflows/sonar.yml
@@ -27,6 +27,7 @@ jobs:
token-check:
runs-on: ubuntu-latest
if: ${{ !(github.event_name == 'pull_request' && startsWith(github.head_ref, 'renovate/')) }}
+ timeout-minutes: 5
outputs:
hasToken: ${{ steps.check-token.outputs.has }}
steps:
@@ -40,6 +41,7 @@ jobs:
runs-on: ubuntu-latest
needs: token-check
if: ${{ needs.token-check.outputs.hasToken }}
+ timeout-minutes: 30
steps:
- uses: actions/checkout@v4
with:
diff --git a/.github/workflows/sync-labels.yml b/.github/workflows/sync-labels.yml
index ff880f07..c9d7ec78 100644
--- a/.github/workflows/sync-labels.yml
+++ b/.github/workflows/sync-labels.yml
@@ -14,6 +14,7 @@ permissions:
jobs:
labels:
runs-on: ubuntu-latest
+ timeout-minutes: 10
steps:
- uses: actions/checkout@v4
with:
diff --git a/.github/workflows/test-deploy.yml b/.github/workflows/test-deploy.yml
index e3ed038b..03f5339e 100644
--- a/.github/workflows/test-deploy.yml
+++ b/.github/workflows/test-deploy.yml
@@ -9,6 +9,7 @@ env:
jobs:
publish-maven:
runs-on: ubuntu-latest
+ timeout-minutes: 60
steps:
- uses: actions/checkout@v4
diff --git a/.github/workflows/update-from-template.yml b/.github/workflows/update-from-template.yml
index aa33de40..6f9497eb 100644
--- a/.github/workflows/update-from-template.yml
+++ b/.github/workflows/update-from-template.yml
@@ -31,6 +31,7 @@ permissions:
jobs:
update:
runs-on: ubuntu-latest
+ timeout-minutes: 60
outputs:
update_branch_merged_commit: ${{ steps.manage-branches.outputs.update_branch_merged_commit }}
create_update_branch_merged_pr: ${{ steps.manage-branches.outputs.create_update_branch_merged_pr }}
@@ -180,6 +181,7 @@ jobs:
needs: [update]
if: needs.update.outputs.create_update_branch_merged_pr == 1
runs-on: ubuntu-latest
+ timeout-minutes: 60
steps:
- uses: actions/checkout@v4
with:
diff --git a/.gitignore b/.gitignore
index 3370dfc0..5de618cb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -67,6 +67,7 @@ spring-data-eclipse-store-demo/storage
spring-data-eclipse-store-demo/storage-person
spring-data-eclipse-store-demo/storage-invoice
spring-data-eclipse-store-demo/storage-complex
+spring-data-eclipse-store-demo/storage-lazy
spring-data-eclipse-store-jpa/storage-eclipsestore
spring-data-eclipse-store-jpa/storage-h2.mv.db
spring-data-eclipse-store-jpa/storage-h2.trace.db
diff --git a/.idea/checkstyle-idea.xml b/.idea/checkstyle-idea.xml
index eb3fcd83..5f35e018 100644
--- a/.idea/checkstyle-idea.xml
+++ b/.idea/checkstyle-idea.xml
@@ -1,7 +1,7 @@
- 10.15.0
+ 10.20.1JavaOnlyWithTeststruetrue
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 95b2e41f..90f08446 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,9 @@
+# 2.4.0
+
+* Updated org.springframework.boot.version to v3.4.0
+* Updated EclipseStore to v2.0.0
+* Implemented Lazy Repositories with ``LazyEclipseStoreRepository``
+
# 2.3.1
* Auto-Fix problems with adding ids to entities with existing data store.
diff --git a/README.md b/README.md
index 5cdd4105..e177eb9b 100644
--- a/README.md
+++ b/README.md
@@ -56,7 +56,8 @@ instructions** are in the documentation](https://xdev-software.github.io/spring-
| ``1.0.5-1.0.7`` | ``17`` | ``3.2.5`` | ``1.3.2`` |
| ``1.0.8-1.0.10`` | ``17`` | ``3.3.1`` | ``1.3.2`` |
| ``2.0.0-2.1.0`` | ``17`` | ``3.3.2`` | ``1.4.0`` |
-| ``>= 2.2.0`` | ``17`` | ``3.3.4`` | ``1.4.0`` |
+| ``2.2.0-2.3.1`` | ``17`` | ``3.3.4`` | ``1.4.0`` |
+| ``>= 2.4.0`` | ``17`` | ``3.4.0`` | ``2.0.0`` |
## Demo
@@ -65,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/antora.yml b/docs/antora.yml
index 4875528b..56709584 100644
--- a/docs/antora.yml
+++ b/docs/antora.yml
@@ -1,14 +1,14 @@
name: ROOT
title: Spring-Data-Eclipse-Store
version: master
-display_version: '2.3.1'
+display_version: '2.4.0'
start_page: index.adoc
nav:
- modules/ROOT/nav.adoc
asciidoc:
attributes:
product-name: 'Spring-Data-Eclipse-Store'
- display-version: '2.3.1'
- maven-version: '2.3.1'
+ display-version: '2.4.0'
+ maven-version: '2.4.0'
page-editable: false
page-out-of-support: false
diff --git a/docs/modules/ROOT/pages/features/lazies.adoc b/docs/modules/ROOT/pages/features/lazies.adoc
index 80a04834..371bd903 100644
--- a/docs/modules/ROOT/pages/features/lazies.adoc
+++ b/docs/modules/ROOT/pages/features/lazies.adoc
@@ -27,10 +27,38 @@ public class Owner extends Person
{
private String address;
- private Lazy> pets = SpringDataEclipseStoreLazy.build(new ArrayList<>());
+ private final Lazy> pets = SpringDataEclipseStoreLazy.build(new ArrayList<>());
//...
----
+== 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.
diff --git a/docs/package.json b/docs/package.json
index d8693534..a8b88ac2 100644
--- a/docs/package.json
+++ b/docs/package.json
@@ -3,7 +3,7 @@
"@antora/lunr-extension": "^1.0.0-alpha.8"
},
"devDependencies": {
- "@antora/cli": "3.1.9",
- "@antora/site-generator": "3.1.9"
+ "@antora/cli": "3.1.10",
+ "@antora/site-generator": "3.1.10"
}
}
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index c6b4bc29..a9c27307 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
software.xdevspring-data-eclipse-store-root
- 2.3.2-SNAPSHOT
+ 2.4.0-SNAPSHOTpom
@@ -45,12 +45,12 @@
org.apache.maven.pluginsmaven-checkstyle-plugin
- 3.5.0
+ 3.6.0com.puppycrawl.toolscheckstyle
- 10.18.2
+ 10.20.2
@@ -75,7 +75,7 @@
org.apache.maven.pluginsmaven-pmd-plugin
- 3.25.0
+ 3.26.0truetrue
@@ -93,12 +93,12 @@
net.sourceforge.pmdpmd-core
- 7.6.0
+ 7.8.0net.sourceforge.pmdpmd-java
- 7.6.0
+ 7.8.0
@@ -110,7 +110,7 @@
org.apache.maven.pluginsmaven-jxr-plugin
- 3.5.0
+ 3.6.0
diff --git a/spring-data-eclipse-store-benchmark/pom.xml b/spring-data-eclipse-store-benchmark/pom.xml
index 4032e860..e9a4cc1f 100644
--- a/spring-data-eclipse-store-benchmark/pom.xml
+++ b/spring-data-eclipse-store-benchmark/pom.xml
@@ -5,11 +5,11 @@
software.xdevspring-data-eclipse-store-root
- 2.3.2-SNAPSHOT
+ 2.4.0-SNAPSHOTspring-data-eclipse-store-benchmark
- 2.3.2-SNAPSHOT
+ 2.4.0-SNAPSHOTjar2023
@@ -25,7 +25,7 @@
UTF-8UTF-8
- 3.3.4
+ 3.4.01.37
diff --git a/spring-data-eclipse-store-demo/pom.xml b/spring-data-eclipse-store-demo/pom.xml
index 706e7357..b36c5664 100644
--- a/spring-data-eclipse-store-demo/pom.xml
+++ b/spring-data-eclipse-store-demo/pom.xml
@@ -7,11 +7,11 @@
software.xdevspring-data-eclipse-store-root
- 2.3.2-SNAPSHOT
+ 2.4.0-SNAPSHOTspring-data-eclipse-store-demo
- 2.3.2-SNAPSHOT
+ 2.4.0-SNAPSHOTjar
@@ -28,7 +28,7 @@
software.xdev.spring.data.eclipse.store.demo.complex.ComplexDemoApplication
- 3.3.4
+ 3.4.0
@@ -113,7 +113,7 @@
org.apache.maven.pluginsmaven-surefire-plugin
- 3.5.0
+ 3.5.2
--add-opens java.base/java.util=ALL-UNNAMED
diff --git a/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/lazy/Customer.java b/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/lazy/Customer.java
new file mode 100644
index 00000000..191e38c8
--- /dev/null
+++ b/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/lazy/Customer.java
@@ -0,0 +1,31 @@
+package software.xdev.spring.data.eclipse.store.demo.lazy;
+
+import jakarta.persistence.GeneratedValue;
+import jakarta.persistence.GenerationType;
+
+import org.springframework.data.annotation.Id;
+
+
+public class Customer
+{
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ private String id;
+
+ private final String firstName;
+ private final String lastName;
+
+ public Customer(final String firstName, final String lastName)
+ {
+ this.firstName = firstName;
+ this.lastName = lastName;
+ }
+
+ @Override
+ public String toString()
+ {
+ return String.format(
+ "Customer[id=%s, firstName='%s', lastName='%s']",
+ this.id, this.firstName, this.lastName);
+ }
+}
diff --git a/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/lazy/CustomerRepository.java b/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/lazy/CustomerRepository.java
new file mode 100644
index 00000000..7c0edc1d
--- /dev/null
+++ b/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/lazy/CustomerRepository.java
@@ -0,0 +1,8 @@
+package software.xdev.spring.data.eclipse.store.demo.lazy;
+
+import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStoreCrudRepository;
+
+
+public interface CustomerRepository extends LazyEclipseStoreCrudRepository
+{
+}
diff --git a/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/lazy/LazyConfiguration.java b/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/lazy/LazyConfiguration.java
new file mode 100644
index 00000000..a17df36c
--- /dev/null
+++ b/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/lazy/LazyConfiguration.java
@@ -0,0 +1,52 @@
+package software.xdev.spring.data.eclipse.store.demo.lazy;
+
+import java.nio.file.Path;
+
+import org.eclipse.serializer.reflect.ClassLoaderProvider;
+import org.eclipse.store.integrations.spring.boot.types.configuration.EclipseStoreProperties;
+import org.eclipse.store.integrations.spring.boot.types.factories.EmbeddedStorageFoundationFactory;
+import org.eclipse.store.storage.embedded.types.EmbeddedStorage;
+import org.eclipse.store.storage.embedded.types.EmbeddedStorageFoundation;
+import org.eclipse.store.storage.types.Storage;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Configuration;
+
+import software.xdev.spring.data.eclipse.store.demo.dual.storage.person.PersistencePersonConfiguration;
+import software.xdev.spring.data.eclipse.store.repository.config.EclipseStoreClientConfiguration;
+import software.xdev.spring.data.eclipse.store.repository.config.EnableEclipseStoreRepositories;
+
+
+@Configuration
+@EnableEclipseStoreRepositories
+public class LazyConfiguration extends EclipseStoreClientConfiguration
+{
+
+ public static final String STORAGE_PATH = "storage-lazy";
+
+ @Autowired
+ public LazyConfiguration(
+ final EclipseStoreProperties defaultEclipseStoreProperties,
+ final EmbeddedStorageFoundationFactory defaultEclipseStoreProvider,
+ final ClassLoaderProvider classLoaderProvider
+ )
+ {
+ super(defaultEclipseStoreProperties, defaultEclipseStoreProvider, classLoaderProvider);
+ }
+ /**
+ * This is one option how to configure the {@link EmbeddedStorageFoundation}.
+ *
+ * We create a completely new foundation. That means that all configuration (e.g. properties) are not used here.
+ * With this method you have complete control over the configuration.
+ *
+ * Another example: {@link PersistencePersonConfiguration#createEmbeddedStorageFoundation()}
+ */
+ @Override
+ public EmbeddedStorageFoundation> createEmbeddedStorageFoundation()
+ {
+ final EmbeddedStorageFoundation> storageFoundation =
+ EmbeddedStorage.Foundation(Storage.Configuration(Storage.FileProvider(Path.of(STORAGE_PATH))));
+ // This is only needed, if a different ClassLoader is used (e.g. when using spring-dev-tools)
+ storageFoundation.getConnectionFoundation().setClassLoaderProvider(this.getClassLoaderProvider());
+ return storageFoundation;
+ }
+}
diff --git a/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/lazy/LazyDemoApplication.java b/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/lazy/LazyDemoApplication.java
new file mode 100644
index 00000000..7fcd5ec8
--- /dev/null
+++ b/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/lazy/LazyDemoApplication.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2012-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package software.xdev.spring.data.eclipse.store.demo.lazy;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.boot.CommandLineRunner;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+
+@SpringBootApplication
+public class LazyDemoApplication implements CommandLineRunner
+{
+ private static final Logger LOG = LoggerFactory.getLogger(LazyDemoApplication.class);
+ private final CustomerRepository customerRepository;
+ private final PetRepository petRepository;
+
+ public LazyDemoApplication(
+ final CustomerRepository customerRepository,
+ final PetRepository petRepository
+ )
+ {
+ this.customerRepository = customerRepository;
+ this.petRepository = petRepository;
+ }
+
+ public static void main(final String[] args)
+ {
+ SpringApplication.run(LazyDemoApplication.class, args);
+ }
+
+ @Override
+ public void run(final String... args)
+ {
+ this.customerRepository.deleteAll();
+
+ // save a couple of customers
+ this.customerRepository.save(new Customer("Stevie", "Nicks"));
+ this.customerRepository.save(new Customer("Mick", "Fleetwood"));
+
+ // fetch all customers
+ LOG.info("Customers found with findAll():");
+ this.customerRepository.findAll().forEach(c -> LOG.info(c.toString()));
+
+ // save a pet
+ this.petRepository.save(new Pet("1", "Peter", 2));
+
+ // fetch all pets
+ LOG.info("Pets found with findAll():");
+ this.petRepository.findAll().forEach(p -> LOG.info(p.toString()));
+ }
+}
diff --git a/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/lazy/Pet.java b/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/lazy/Pet.java
new file mode 100644
index 00000000..6a36915b
--- /dev/null
+++ b/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/lazy/Pet.java
@@ -0,0 +1,32 @@
+package software.xdev.spring.data.eclipse.store.demo.lazy;
+
+import org.springframework.data.annotation.Id;
+
+
+public class Pet
+{
+ @Id
+ private String id;
+
+ private String name;
+ private Integer age;
+
+ public Pet()
+ {
+ }
+
+ public Pet(final String id, final String name, final Integer age)
+ {
+ this.id = id;
+ this.name = name;
+ this.age = age;
+ }
+
+ @Override
+ public String toString()
+ {
+ return String.format(
+ "Pet[id=%s, name='%s', age='%s']",
+ this.id, this.name, this.age);
+ }
+}
diff --git a/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/lazy/PetRepository.java b/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/lazy/PetRepository.java
new file mode 100644
index 00000000..2cba129d
--- /dev/null
+++ b/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/lazy/PetRepository.java
@@ -0,0 +1,8 @@
+package software.xdev.spring.data.eclipse.store.demo.lazy;
+
+import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStoreCrudRepository;
+
+
+public interface PetRepository extends LazyEclipseStoreCrudRepository
+{
+}
diff --git a/spring-data-eclipse-store-demo/src/test/java/software/xdev/spring/data/eclipse/store/demo/lazy/complex/LazyDemoApplicationTest.java b/spring-data-eclipse-store-demo/src/test/java/software/xdev/spring/data/eclipse/store/demo/lazy/complex/LazyDemoApplicationTest.java
new file mode 100644
index 00000000..f6a7cd6f
--- /dev/null
+++ b/spring-data-eclipse-store-demo/src/test/java/software/xdev/spring/data/eclipse/store/demo/lazy/complex/LazyDemoApplicationTest.java
@@ -0,0 +1,39 @@
+package software.xdev.spring.data.eclipse.store.demo.lazy.complex;
+
+import java.io.File;
+
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+import software.xdev.spring.data.eclipse.store.demo.TestUtil;
+import software.xdev.spring.data.eclipse.store.demo.lazy.LazyConfiguration;
+import software.xdev.spring.data.eclipse.store.demo.lazy.LazyDemoApplication;
+import software.xdev.spring.data.eclipse.store.repository.config.EclipseStoreClientConfiguration;
+
+
+@SpringBootTest(classes = LazyDemoApplication.class)
+class LazyDemoApplicationTest
+{
+ private final EclipseStoreClientConfiguration configuration;
+
+ @Autowired
+ public LazyDemoApplicationTest(final LazyConfiguration configuration)
+ {
+ this.configuration = configuration;
+ }
+
+ @BeforeAll
+ static void clearPreviousData()
+ {
+ TestUtil.deleteDirectory(new File("./" + LazyConfiguration.STORAGE_PATH));
+ }
+
+ @Test
+ void checkPossibilityToSimplyStartAndRestartApplication()
+ {
+ this.configuration.getStorageInstance().stop();
+ LazyDemoApplication.main(new String[]{});
+ }
+}
diff --git a/spring-data-eclipse-store-jpa/pom.xml b/spring-data-eclipse-store-jpa/pom.xml
index 1c8f9a9a..d06dacf3 100644
--- a/spring-data-eclipse-store-jpa/pom.xml
+++ b/spring-data-eclipse-store-jpa/pom.xml
@@ -7,11 +7,11 @@
software.xdevspring-data-eclipse-store-root
- 2.3.2-SNAPSHOT
+ 2.4.0-SNAPSHOTspring-data-eclipse-store-jpa
- 2.3.2-SNAPSHOT
+ 2.4.0-SNAPSHOTjar2023
@@ -30,7 +30,7 @@
software.xdev.spring.data.eclipse.store.demo.complex.ComplexDemoApplication
- 3.3.4
+ 3.4.0
diff --git a/spring-data-eclipse-store/pom.xml b/spring-data-eclipse-store/pom.xml
index 8d3b0277..ed00db8c 100644
--- a/spring-data-eclipse-store/pom.xml
+++ b/spring-data-eclipse-store/pom.xml
@@ -6,7 +6,7 @@
software.xdevspring-data-eclipse-store
- 2.3.2-SNAPSHOT
+ 2.4.0-SNAPSHOTjarspring-data-eclipse-store
@@ -51,13 +51,13 @@
UTF-8
- 3.3.4
- 1.4.0
- 1.4.0
+ 3.4.0
+ 2.0.0
+ 2.0.08.0.1.Final6.0.16.0.0-M1
- 6.6.1.Final
+ 6.6.3.Final
@@ -274,7 +274,7 @@
org.apache.maven.pluginsmaven-project-info-reports-plugin
- 3.7.0
+ 3.8.0
@@ -314,6 +314,8 @@
maven-compiler-plugin3.13.0
+ ${javaVersion}
+ ${javaVersion}${maven.compiler.release}-proc:none
@@ -323,11 +325,11 @@
org.apache.maven.pluginsmaven-javadoc-plugin
- 3.10.1
+ 3.11.2attach-javadocs
- verify
+ packagejar
@@ -341,7 +343,7 @@
org.apache.maven.pluginsmaven-surefire-plugin
- 3.5.0
+ 3.5.2
--add-exports java.base/jdk.internal.misc=ALL-UNNAMED
@@ -358,7 +360,7 @@
attach-sources
- verify
+ packagejar-no-fork
@@ -435,12 +437,12 @@
org.apache.maven.pluginsmaven-checkstyle-plugin
- 3.5.0
+ 3.6.0com.puppycrawl.toolscheckstyle
- 10.18.2
+ 10.20.2
@@ -465,7 +467,7 @@
org.apache.maven.pluginsmaven-pmd-plugin
- 3.25.0
+ 3.26.0truetrue
@@ -482,12 +484,12 @@
net.sourceforge.pmdpmd-core
- 7.6.0
+ 7.8.0net.sourceforge.pmdpmd-java
- 7.6.0
+ 7.8.0
@@ -499,7 +501,7 @@
org.apache.maven.pluginsmaven-jxr-plugin
- 3.5.0
+ 3.6.0
diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/core/EntityListProvider.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/core/EntityListProvider.java
index 6114fef8..7a538164 100644
--- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/core/EntityListProvider.java
+++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/core/EntityListProvider.java
@@ -18,6 +18,4 @@
public interface EntityListProvider
{
EntityProvider getEntityProvider(final Class clazz);
-
- long getEntityCount(final Class clazz);
}
diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/core/EntityProvider.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/core/EntityProvider.java
index 8a8ff19f..0fdfd649 100644
--- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/core/EntityProvider.java
+++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/core/EntityProvider.java
@@ -18,12 +18,12 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
+import java.util.Objects;
import java.util.Optional;
-import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
-import software.xdev.spring.data.eclipse.store.repository.root.EntityData;
+import software.xdev.spring.data.eclipse.store.repository.root.v2_4.EntityData;
@SuppressWarnings("java:S119")
@@ -38,7 +38,7 @@ public void addEntityData(final EntityData extends T, ID> entityData)
public Stream extends T> stream()
{
- return this.entityDataList.stream().map(EntityData::getEntities).flatMap(Set::stream);
+ return this.entityDataList.stream().flatMap(EntityData::getEntitiesAsStream);
}
public Collection toCollection()
@@ -56,12 +56,13 @@ public long size()
return this.stream().count();
}
+ @SuppressWarnings("unchecked")
public Optional findAnyEntityWithId(final ID id)
{
return (Optional)this.entityDataList
.stream()
- .map(entityData -> entityData.getEntitiesById().get(id))
- .filter(e -> e != null)
+ .map(entityData -> entityData.getEntityById(id))
+ .filter(Objects::nonNull)
.findAny();
}
}
diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/EclipseStoreMigrator.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/EclipseStoreMigrator.java
index f37eaf5d..695f0504 100644
--- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/EclipseStoreMigrator.java
+++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/EclipseStoreMigrator.java
@@ -25,13 +25,15 @@
import software.xdev.micromigration.version.MigrationVersion;
import software.xdev.spring.data.eclipse.store.repository.root.VersionedRoot;
import software.xdev.spring.data.eclipse.store.repository.root.update.scripts.v2_0_0_InitializeVersioning;
+import software.xdev.spring.data.eclipse.store.repository.root.update.scripts.v2_4_0_InitializeLazy;
public final class EclipseStoreMigrator
{
public static final VersionAgnosticMigrationScript, ?>[] SCRIPTS =
new VersionAgnosticMigrationScript[]{
- new v2_0_0_InitializeVersioning()
+ new v2_0_0_InitializeVersioning(),
+ new v2_4_0_InitializeLazy()
};
private EclipseStoreMigrator()
diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/EclipseStoreStorage.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/EclipseStoreStorage.java
index 4f902583..a92213b7 100644
--- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/EclipseStoreStorage.java
+++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/EclipseStoreStorage.java
@@ -38,8 +38,9 @@
import software.xdev.spring.data.eclipse.store.exceptions.InvalidRootException;
import software.xdev.spring.data.eclipse.store.repository.config.EclipseStoreClientConfiguration;
import software.xdev.spring.data.eclipse.store.repository.config.EclipseStoreStorageFoundationProvider;
-import software.xdev.spring.data.eclipse.store.repository.root.EntityData;
+import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreRepository;
import software.xdev.spring.data.eclipse.store.repository.root.VersionedRoot;
+import software.xdev.spring.data.eclipse.store.repository.root.v2_4.EntityData;
import software.xdev.spring.data.eclipse.store.repository.support.SimpleEclipseStoreRepository;
import software.xdev.spring.data.eclipse.store.repository.support.concurrency.ReadWriteLock;
import software.xdev.spring.data.eclipse.store.repository.support.concurrency.ReentrantJavaReadWriteLock;
@@ -53,9 +54,14 @@
import software.xdev.spring.data.eclipse.store.repository.support.reposyncer.SimpleRepositorySynchronizer;
-@SuppressWarnings("java:S119")
+@SuppressWarnings({"java:S119", "PMD.GodClass"})
public class EclipseStoreStorage
- implements EntityListProvider, IdManagerProvider, VersionManagerProvider, PersistableChecker, ObjectSwizzling
+ implements EntityListProvider,
+ IdManagerProvider,
+ VersionManagerProvider,
+ PersistableChecker,
+ ObjectSwizzling,
+ StorageCommunicator
{
private static final Logger LOG = LoggerFactory.getLogger(EclipseStoreStorage.class);
private final Map, SimpleEclipseStoreRepository, ?>> entityClassToRepository = new HashMap<>();
@@ -106,8 +112,7 @@ private synchronized void ensureEntitiesInRoot()
{
if(this.storageManager == null)
{
- final EmbeddedStorageFoundation> embeddedStorageFoundation =
- this.startStorageManager();
+ final EmbeddedStorageFoundation> embeddedStorageFoundation = this.startStorageManager();
this.persistenceChecker = new RelayedPersistenceChecker(embeddedStorageFoundation);
this.initRoot();
LOG.info(
@@ -119,6 +124,7 @@ private synchronized void ensureEntitiesInRoot()
}
}
+ @SuppressWarnings("deprecation")
private EmbeddedStorageFoundation> startStorageManager()
{
LOG.info("Starting storage...");
@@ -155,9 +161,9 @@ else if(!(embeddedStorageManager.root() instanceof VersionedRoot))
return embeddedStorageFoundation;
}
- public SimpleEclipseStoreRepository getRepository(final Class entityClass)
+ public EclipseStoreRepository, ?> getRepository(final Class entityClass)
{
- return (SimpleEclipseStoreRepository)this.entityClassToRepository.get(entityClass);
+ return this.entityClassToRepository.get(entityClass);
}
private void initRoot()
@@ -168,6 +174,19 @@ private void initRoot()
}
this.repositorySynchronizer =
new SimpleRepositorySynchronizer(this.root.getCurrentRootData());
+ this.ensureEntityData();
+ this.entitySetCollector =
+ new EntitySetCollector(
+ this.root.getCurrentRootData()::getEntityData,
+ this.entityClassToRepository.keySet());
+ if(LOG.isDebugEnabled())
+ {
+ LOG.debug("Done initializing entity lists.");
+ }
+ }
+
+ private void ensureEntityData()
+ {
boolean entityListMustGetStored = false;
for(final Class> entityClass : this.entityClassToRepository.keySet())
{
@@ -185,20 +204,20 @@ private void initRoot()
{
this.storageManager.store(this.root.getCurrentRootData().getEntityListsToStore());
}
- this.entitySetCollector =
- new EntitySetCollector(
- this.root.getCurrentRootData()::getEntityData,
- this.entityClassToRepository.keySet());
- if(LOG.isDebugEnabled())
- {
- LOG.debug("Done initializing entity lists.");
- }
}
- private void createNewEntityData(final Class entityClass, final VersionedRoot root)
+ public void createNewEntityData(final Class entityClass, final VersionedRoot root)
{
final IdManager idManager = this.ensureIdManager(entityClass);
- root.getCurrentRootData().createNewEntityData(entityClass, idManager::getId);
+ final SimpleEclipseStoreRepository, ?> repository = this.entityClassToRepository.get(entityClass);
+ if(repository != null && repository.isLazy())
+ {
+ root.getCurrentRootData().createNewLazyEntityData(entityClass, idManager.hasIdField() ? idManager : null);
+ }
+ else
+ {
+ root.getCurrentRootData().createNewEntityData(entityClass, idManager.hasIdField() ? idManager : null);
+ }
}
private void setIdManagerForEntityData(final Class entityClass, final VersionedRoot root)
@@ -215,9 +234,10 @@ private void setIdManagerForEntityData(final Class entityClass, final
}
}
- public synchronized void registerEntity(
+ @Override
+ public synchronized void registerEntity(
final Class classToRegister,
- final SimpleEclipseStoreRepository repository)
+ final SimpleEclipseStoreRepository repository)
{
if(this.entityClassToRepository.containsKey(classToRegister))
{
@@ -236,9 +256,7 @@ public synchronized void registerEntity(
private EntityData getEntityData(final Class clazz)
{
this.ensureEntitiesInRoot();
- return this.readWriteLock.read(
- () -> this.root.getCurrentRootData().getEntityData(clazz)
- );
+ return this.readWriteLock.read(() -> this.root.getCurrentRootData().getEntityData(clazz));
}
@Override
@@ -248,20 +266,17 @@ public EntityProvider getEntityProvider(final Class clazz)
return this.entitySetCollector.getRelatedIdentitySets(clazz);
}
- @SuppressWarnings("unchecked")
@Override
public long getEntityCount(final Class clazz)
{
this.ensureEntitiesInRoot();
- return this.readWriteLock.read(
- () ->
- {
- final EntityData entityData = this.root.getCurrentRootData().getEntityData(clazz);
- return entityData == null ? 0 : entityData.getEntityCount();
- }
- );
+ return this.readWriteLock.read(() -> {
+ final EntityData entityData = this.getEntityData(clazz);
+ return entityData == null ? 0 : entityData.getEntityCount();
+ });
}
+ @Override
public void store(
final Collection