> fam = FieldAccessModifier.prepareForField(
+ objectIdField,
+ wrappedDefaultLazy))
+ {
+ // The lazy object should be seen as "stored" by the LazyManager.
+ // Therefore, we must set the objectId to Swizzling.nullId().
+ fam.writeValueOfField(wrappedDefaultLazy, Swizzling.nullId(), true);
+ }
+ }
+ }
+ catch(final Exception e)
+ {
+ throw new LazyNotUnlinkableException("Could not unlink lazy " + this.wrappedLazy, e);
+ }
+ }
+
+ @Override
+ public boolean isOriginalObject()
+ {
+ return this.objectToBeWrapped != null;
+ }
+ }
+}
diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/lazy/SpringDataEclipseStoreLazyBinaryHandler.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/lazy/SpringDataEclipseStoreLazyBinaryHandler.java
new file mode 100644
index 00000000..a6223a84
--- /dev/null
+++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/lazy/SpringDataEclipseStoreLazyBinaryHandler.java
@@ -0,0 +1,197 @@
+/*
+ * Copyright © 2024 XDEV Software (https://xdev.software)
+ *
+ * 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
+ *
+ * http://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.repository.lazy;
+
+import java.lang.reflect.Constructor;
+import java.util.Objects;
+
+import org.eclipse.serializer.memory.XMemory;
+import org.eclipse.serializer.persistence.binary.types.AbstractBinaryHandlerCustom;
+import org.eclipse.serializer.persistence.binary.types.Binary;
+import org.eclipse.serializer.persistence.binary.types.BinaryTypeHandler;
+import org.eclipse.serializer.persistence.types.PersistenceLoadHandler;
+import org.eclipse.serializer.persistence.types.PersistenceReferenceLoader;
+import org.eclipse.serializer.persistence.types.PersistenceStoreHandler;
+import org.eclipse.serializer.reference.Lazy;
+import org.eclipse.serializer.reference.ObjectSwizzling;
+import org.eclipse.serializer.reflect.XReflect;
+
+import software.xdev.spring.data.eclipse.store.repository.support.copier.working.WorkingCopier;
+
+
+/**
+ * This is a complicated one. First off: this handler should only be used for WorkingCopies (see
+ * {@link
+ * software.xdev.spring.data.eclipse.store.repository.support.copier.registering.EclipseSerializerRegisteringCopier})!
+ *
+ * First case:
+ * The user creates a {@link SpringDataEclipseStoreLazy} and puts a object in it.
+ * This object is stored as with a default {@link BinaryTypeHandler}. But when it gets loaded,
+ * it does not load as the stored object, but it gets wrapped in a {@link Lazy#Reference(Object)}.
+ *
+ *
+ * Second case:
+ * The actual lazy object gets loaded from the actual storage. In this case the {@link ObjectSwizzling} is
+ * important! It's the actual {@link ObjectSwizzling} from the storage (not from the
+ * {@link
+ * software.xdev.spring.data.eclipse.store.repository.support.copier.registering.EclipseSerializerRegisteringCopier}).
+ * This means, the {@link SpringDataEclipseStoreLazy} holds the objectId of the original lazy in the original
+ * storage.
+ * Therefore if {@link SpringDataEclipseStoreLazy#get()} is called a new working copy of the lazy from the
+ * storage is loaded.
+ *
+ */
+public final class SpringDataEclipseStoreLazyBinaryHandler
+ extends AbstractBinaryHandlerCustom>
+{
+ @SuppressWarnings("rawtypes")
+ static final Constructor CONSTRUCTOR_SURROGATE_LAZY = XReflect.setAccessible(
+ XReflect.getDeclaredConstructor(
+ SpringDataEclipseStoreLazy.Default.class,
+ long.class,
+ ObjectSwizzling.class,
+ WorkingCopier.class
+ )
+ );
+
+ private static final int OFFSET_UNWRAPPED_OBJECT = 8;
+ private static final int OFFSET_LAZY = 0;
+
+ private final ObjectSwizzling originalStoreLoader;
+ private final WorkingCopier> copier;
+
+ public SpringDataEclipseStoreLazyBinaryHandler(
+ final ObjectSwizzling originalStoreLoader,
+ final WorkingCopier> copier)
+ {
+ super(
+ // Cast is necessary for the compiler
+ (Class)SpringDataEclipseStoreLazy.Default.class,
+ CustomFields(
+ CustomField(Object.class, "lazySubject"),
+ CustomField(Object.class, "unwrappedSubject")
+ )
+ );
+ this.originalStoreLoader = Objects.requireNonNull(originalStoreLoader);
+ this.copier = Objects.requireNonNull(copier);
+ }
+
+ @Override
+ public void store(
+ final Binary data,
+ final SpringDataEclipseStoreLazy.Default> instance,
+ final long objectId,
+ final PersistenceStoreHandler handler
+ )
+ {
+ data.storeEntityHeader(Binary.referenceBinaryLength(2), this.typeId(), objectId);
+ if(instance.isOriginalObject())
+ {
+ // Store unwrapped Object
+ data.store_long(OFFSET_UNWRAPPED_OBJECT, handler.applyEager(instance.getObjectToBeWrapped()));
+ }
+ else
+ {
+ // Store only reference to lazy
+ data.store_long(OFFSET_LAZY, instance.objectId());
+ }
+ instance.setStored();
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public SpringDataEclipseStoreLazy.Default> create(final Binary data, final PersistenceLoadHandler handler)
+ {
+ final long objectIdOfLazy = data.read_long(OFFSET_LAZY);
+ final long objectIdOfUnwrappedObject = data.read_long(OFFSET_UNWRAPPED_OBJECT);
+
+ if(objectIdOfUnwrappedObject == 0)
+ {
+ return Lazy.register(
+ XReflect.invoke(CONSTRUCTOR_SURROGATE_LAZY, objectIdOfLazy, this.originalStoreLoader, this.copier)
+ );
+ }
+ return XMemory.instantiateBlank(SpringDataEclipseStoreLazy.Default.class);
+ }
+
+ @Override
+ public void updateState(
+ final Binary data,
+ final SpringDataEclipseStoreLazy.Default> instance,
+ final PersistenceLoadHandler handler
+ )
+ {
+ this.updateStateT(data, instance, handler);
+ }
+
+ private void updateStateT(
+ final Binary data,
+ final SpringDataEclipseStoreLazy.Default instance,
+ final PersistenceLoadHandler handler
+ )
+ {
+ final long objectIdOfUnwrappedObject = data.read_long(OFFSET_UNWRAPPED_OBJECT);
+
+ if(objectIdOfUnwrappedObject != 0)
+ {
+ instance.setWrappedLazy(Lazy.Reference((T)handler.lookupObject(objectIdOfUnwrappedObject)));
+ // Is already stored in the main storage.
+ instance.setStored();
+ }
+ }
+
+ @Override
+ public final void complete(
+ final Binary data,
+ final SpringDataEclipseStoreLazy.Default> instance,
+ final PersistenceLoadHandler handler
+ )
+ {
+ // no-op for normal implementation (see non-reference-hashing collections for other examples)
+ }
+
+ @Override
+ public final boolean hasPersistedReferences()
+ {
+ return true;
+ }
+
+ @Override
+ public final boolean hasPersistedVariableLength()
+ {
+ return false;
+ }
+
+ @Override
+ public final boolean hasVaryingPersistedLengthInstances()
+ {
+ return false;
+ }
+
+ @Override
+ public final void iterateLoadableReferences(
+ final Binary data,
+ final PersistenceReferenceLoader iterator
+ )
+ {
+ final long objectIdOfUnwrappedObject = data.read_long(OFFSET_UNWRAPPED_OBJECT);
+
+ if(objectIdOfUnwrappedObject != 0)
+ {
+ iterator.acceptObjectId(objectIdOfUnwrappedObject);
+ }
+ }
+}
diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/EclipseStoreQueryCreator.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/EclipseStoreQueryCreator.java
index fb685694..6bed9ef5 100644
--- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/EclipseStoreQueryCreator.java
+++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/EclipseStoreQueryCreator.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/FindAllEclipseStoreQueryProvider.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/FindAllEclipseStoreQueryProvider.java
index 77e2de71..175e47b6 100644
--- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/FindAllEclipseStoreQueryProvider.java
+++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/FindAllEclipseStoreQueryProvider.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/ReflectedField.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/ReflectedField.java
index f3ece752..2fb19a78 100644
--- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/ReflectedField.java
+++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/ReflectedField.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/StringBasedEclipseStoreQueryProvider.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/StringBasedEclipseStoreQueryProvider.java
index 9fdfd8ca..957e958b 100644
--- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/StringBasedEclipseStoreQueryProvider.java
+++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/StringBasedEclipseStoreQueryProvider.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/criteria/AbstractCriteriaNode.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/criteria/AbstractCriteriaNode.java
index 876e3e42..fc62538a 100644
--- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/criteria/AbstractCriteriaNode.java
+++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/criteria/AbstractCriteriaNode.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/criteria/Criteria.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/criteria/Criteria.java
index 1ea456cd..7a211d7c 100644
--- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/criteria/Criteria.java
+++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/criteria/Criteria.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/criteria/CriteriaAndNode.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/criteria/CriteriaAndNode.java
index adcf44b4..0c683857 100644
--- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/criteria/CriteriaAndNode.java
+++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/criteria/CriteriaAndNode.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/criteria/CriteriaOrNode.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/criteria/CriteriaOrNode.java
index d7e84dd9..4e22b1b3 100644
--- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/criteria/CriteriaOrNode.java
+++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/criteria/CriteriaOrNode.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/criteria/CriteriaSingleNode.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/criteria/CriteriaSingleNode.java
index e6eddeeb..a0237d39 100644
--- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/criteria/CriteriaSingleNode.java
+++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/criteria/CriteriaSingleNode.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/executors/EntitySorter.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/executors/EntitySorter.java
index b34e1efb..48d7e5d9 100644
--- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/executors/EntitySorter.java
+++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/executors/EntitySorter.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/executors/ListQueryExecutor.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/executors/ListQueryExecutor.java
index 3a9d13e8..535036a2 100644
--- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/executors/ListQueryExecutor.java
+++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/executors/ListQueryExecutor.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/executors/PageableQueryExecutor.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/executors/PageableQueryExecutor.java
index cb4fe7ce..c21ffe16 100644
--- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/executors/PageableQueryExecutor.java
+++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/executors/PageableQueryExecutor.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/executors/PageableSortableCollectionQuerier.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/executors/PageableSortableCollectionQuerier.java
index 25dc3923..13901115 100644
--- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/executors/PageableSortableCollectionQuerier.java
+++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/executors/PageableSortableCollectionQuerier.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/executors/QueryExecutor.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/executors/QueryExecutor.java
index ebe92070..c2b312af 100644
--- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/executors/QueryExecutor.java
+++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/executors/QueryExecutor.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/executors/QueryExecutorCreator.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/executors/QueryExecutorCreator.java
index c5027e90..f802a9a8 100644
--- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/executors/QueryExecutorCreator.java
+++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/executors/QueryExecutorCreator.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/executors/SingleOptionalQueryExecutor.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/executors/SingleOptionalQueryExecutor.java
index eb06865b..ef0a98fa 100644
--- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/executors/SingleOptionalQueryExecutor.java
+++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/executors/SingleOptionalQueryExecutor.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/executors/SingleQueryExecutor.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/executors/SingleQueryExecutor.java
index 620cfd9f..d5f1c95f 100644
--- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/executors/SingleQueryExecutor.java
+++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/query/executors/SingleQueryExecutor.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/EclipseStoreQueryLookupStrategy.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/EclipseStoreQueryLookupStrategy.java
index 3f0bf32b..06ca3f2b 100644
--- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/EclipseStoreQueryLookupStrategy.java
+++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/EclipseStoreQueryLookupStrategy.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/EclipseStoreRepositoryFactory.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/EclipseStoreRepositoryFactory.java
index 2f42894f..f5ab612c 100644
--- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/EclipseStoreRepositoryFactory.java
+++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/EclipseStoreRepositoryFactory.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -86,7 +86,8 @@ private WorkingCopier createWorkingCopier(
storage.getRegistry(),
storage,
storage,
- new SupportedChecker.Implementation()
+ new SupportedChecker.Implementation(),
+ storage
);
}
diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/EclipseStoreRepositoryFactoryBean.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/EclipseStoreRepositoryFactoryBean.java
index 4c54c4b9..fb859e62 100644
--- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/EclipseStoreRepositoryFactoryBean.java
+++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/EclipseStoreRepositoryFactoryBean.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,7 +25,7 @@
import org.springframework.data.repository.core.support.RepositoryFactorySupport;
import org.springframework.stereotype.Component;
-import software.xdev.spring.data.eclipse.store.repository.EclipseStoreStorage;
+import software.xdev.spring.data.eclipse.store.repository.config.EclipseStoreClientConfiguration;
@ComponentScan({
@@ -35,20 +35,22 @@
public class EclipseStoreRepositoryFactoryBean, S, ID extends Serializable>
extends RepositoryFactoryBeanSupport
{
- private final EclipseStoreStorage storage;
+ private EclipseStoreClientConfiguration configuration;
- public EclipseStoreRepositoryFactoryBean(
- final Class extends T> repositoryInterface,
- final EclipseStoreStorage storage)
+ public EclipseStoreRepositoryFactoryBean(final Class extends T> repositoryInterface)
{
super(repositoryInterface);
- this.storage = storage;
+ }
+
+ public void setConfiguration(final EclipseStoreClientConfiguration configuration)
+ {
+ this.configuration = configuration;
}
@Override
@Nonnull
protected RepositoryFactorySupport createRepositoryFactory()
{
- return new EclipseStoreRepositoryFactory(this.storage);
+ return new EclipseStoreRepositoryFactory(this.configuration.getStorageInstance());
}
}
diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/IdFieldFinder.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/IdFieldFinder.java
index c956cf6a..2e0a31e5 100644
--- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/IdFieldFinder.java
+++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/IdFieldFinder.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/SimpleEclipseStoreRepository.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/SimpleEclipseStoreRepository.java
index b366c873..8e5ef8cc 100644
--- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/SimpleEclipseStoreRepository.java
+++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/SimpleEclipseStoreRepository.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -151,7 +151,7 @@ public Optional findById(@Nonnull final ID id)
{
for(final T entity : this.storage.getEntityList(this.domainClass))
{
- try(final FieldAccessModifier fam = FieldAccessModifier.makeFieldReadable(this.getIdField(), entity))
+ try(final FieldAccessModifier fam = FieldAccessModifier.prepareForField(this.getIdField(), entity))
{
if(id.equals(fam.getValueOfField(entity)))
{
@@ -173,7 +173,7 @@ public boolean existsById(@Nonnull final ID id)
{
for(final T entity : this.storage.getEntityList(this.domainClass))
{
- try(final FieldAccessModifier fam = FieldAccessModifier.makeFieldReadable(this.getIdField(), entity))
+ try(final FieldAccessModifier fam = FieldAccessModifier.prepareForField(this.getIdField(), entity))
{
if(id.equals(fam.getValueOfField(entity)))
{
@@ -204,7 +204,7 @@ public List findAllById(@Nonnull final Iterable ids)
final List foundEntities = new ArrayList<>();
for(final T entity : this.storage.getEntityList(this.domainClass))
{
- try(final FieldAccessModifier fam = FieldAccessModifier.makeFieldReadable(this.getIdField(), entity))
+ try(final FieldAccessModifier fam = FieldAccessModifier.prepareForField(this.getIdField(), entity))
{
for(final ID id : ids)
{
diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/DataTypeUtil.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/DataTypeUtil.java
index 0e6fc2de..7101400d 100644
--- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/DataTypeUtil.java
+++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/DataTypeUtil.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,6 +20,8 @@
import jakarta.annotation.Nonnull;
+import software.xdev.spring.data.eclipse.store.repository.lazy.SpringDataEclipseStoreLazy;
+
public final class DataTypeUtil
{
@@ -45,6 +47,11 @@ public static boolean isObjectArray(final Object obj)
return obj instanceof Object[];
}
+ public static boolean isSpringDataEclipseStoreLazy(final Object obj)
+ {
+ return obj instanceof SpringDataEclipseStoreLazy>;
+ }
+
public static boolean isPrimitiveArray(final Object obj)
{
return obj instanceof boolean[]
diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/id/IdSetter.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/id/IdSetter.java
index f3a08497..9a2f1da0 100644
--- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/id/IdSetter.java
+++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/id/IdSetter.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/id/NotSettingIdSetter.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/id/NotSettingIdSetter.java
index 4177bf27..c299b55d 100644
--- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/id/NotSettingIdSetter.java
+++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/id/NotSettingIdSetter.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/id/SimpleIdSetter.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/id/SimpleIdSetter.java
index 5c7a5975..e59bc75f 100644
--- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/id/SimpleIdSetter.java
+++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/id/SimpleIdSetter.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -53,7 +53,7 @@ private void checkIfIdFieldIsFinal()
@Override
public void ensureId(final T objectToSetIdIn)
{
- try(final FieldAccessModifier fam = FieldAccessModifier.makeFieldReadable(
+ try(final FieldAccessModifier fam = FieldAccessModifier.prepareForField(
this.idField,
objectToSetIdIn))
{
diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/id/strategy/IdFinder.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/id/strategy/IdFinder.java
index b26de773..2618fa2b 100644
--- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/id/strategy/IdFinder.java
+++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/id/strategy/IdFinder.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/id/strategy/auto/AbstractAutoIdFinder.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/id/strategy/auto/AbstractAutoIdFinder.java
index ac603696..beb768f2 100644
--- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/id/strategy/auto/AbstractAutoIdFinder.java
+++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/id/strategy/auto/AbstractAutoIdFinder.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/id/strategy/auto/AutoIntegerIdFinder.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/id/strategy/auto/AutoIntegerIdFinder.java
index 39602d50..0f4b4535 100644
--- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/id/strategy/auto/AutoIntegerIdFinder.java
+++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/id/strategy/auto/AutoIntegerIdFinder.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/id/strategy/auto/AutoLongIdFinder.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/id/strategy/auto/AutoLongIdFinder.java
index db1e5ea9..b3b41e56 100644
--- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/id/strategy/auto/AutoLongIdFinder.java
+++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/id/strategy/auto/AutoLongIdFinder.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/id/strategy/auto/AutoStringIdFinder.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/id/strategy/auto/AutoStringIdFinder.java
index c4e835eb..afc2cbca 100644
--- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/id/strategy/auto/AutoStringIdFinder.java
+++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/id/strategy/auto/AutoStringIdFinder.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/registering/AbstractRegisteringCopier.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/registering/AbstractRegisteringCopier.java
new file mode 100644
index 00000000..d5bc900d
--- /dev/null
+++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/registering/AbstractRegisteringCopier.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright © 2024 XDEV Software (https://xdev.software)
+ *
+ * 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
+ *
+ * http://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.repository.support.copier.registering;
+
+import org.eclipse.serializer.Serializer;
+import org.eclipse.serializer.SerializerFoundation;
+import org.eclipse.serializer.persistence.binary.jdk17.java.util.BinaryHandlerImmutableCollectionsList12;
+import org.eclipse.serializer.persistence.binary.jdk17.java.util.BinaryHandlerImmutableCollectionsSet12;
+import org.eclipse.serializer.persistence.binary.types.Binary;
+import org.eclipse.serializer.persistence.types.PersistenceManager;
+import org.eclipse.serializer.reference.ObjectSwizzling;
+import org.eclipse.serializer.reference.Reference;
+import org.eclipse.serializer.util.X;
+
+import software.xdev.spring.data.eclipse.store.repository.SupportedChecker;
+import software.xdev.spring.data.eclipse.store.repository.lazy.SpringDataEclipseStoreLazyBinaryHandler;
+import software.xdev.spring.data.eclipse.store.repository.support.copier.working.WorkingCopier;
+
+
+/**
+ * This class registers storage instances and copy them for working copies. Utilizes
+ * {@link EclipseSerializerRegisteringCopier}.
+ */
+public abstract class AbstractRegisteringCopier implements RegisteringObjectCopier
+{
+ private final EclipseSerializerRegisteringCopier actualCopier;
+
+ protected AbstractRegisteringCopier(
+ final SupportedChecker supportedChecker,
+ final RegisteringWorkingCopyAndOriginal register,
+ final ObjectSwizzling objectSwizzling,
+ final WorkingCopier> copier)
+ {
+ this.actualCopier = new EclipseSerializerRegisteringCopier(
+ supportedChecker,
+ register,
+ this.createPersistenceManager(
+ this.createSerializerFoundation(),
+ objectSwizzling,
+ copier
+ )
+ );
+ }
+
+ private PersistenceManager createPersistenceManager(
+ final SerializerFoundation> serializerFoundation,
+ final ObjectSwizzling objectSwizzling,
+ final WorkingCopier> copier)
+ {
+ return serializerFoundation
+ .registerCustomTypeHandler(BinaryHandlerImmutableCollectionsSet12.New())
+ .registerCustomTypeHandler(BinaryHandlerImmutableCollectionsList12.New())
+ .registerCustomTypeHandlers(new SpringDataEclipseStoreLazyBinaryHandler(objectSwizzling, copier))
+ .createPersistenceManager();
+ }
+
+ @SuppressWarnings("java:S1452")
+ protected SerializerFoundation> createSerializerFoundation()
+ {
+ final Reference buffer = X.Reference(null);
+ final Serializer.Source source = () -> X.Constant(buffer.get());
+ final Serializer.Target target = buffer::set;
+
+ return SerializerFoundation.New()
+ .setPersistenceSource(source)
+ .setPersistenceTarget(target)
+ // Make every type persistable.
+ // This is quite dangerous!
+ // But if this is not set we get problems e.g. with HashMap$Node
+ .setTypeEvaluatorPersistable(a -> true);
+ }
+
+ @Override
+ public synchronized T copy(final T source)
+ {
+ return this.actualCopier.copy(source);
+ }
+
+ @Override
+ public synchronized void close()
+ {
+ this.actualCopier.close();
+ }
+}
diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/object/EclipseSerializerRegisteringCopier.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/registering/EclipseSerializerRegisteringCopier.java
similarity index 65%
rename from spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/object/EclipseSerializerRegisteringCopier.java
rename to spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/registering/EclipseSerializerRegisteringCopier.java
index 00f6f8e5..5ec09598 100644
--- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/object/EclipseSerializerRegisteringCopier.java
+++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/registering/EclipseSerializerRegisteringCopier.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,28 +13,21 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package software.xdev.spring.data.eclipse.store.repository.support.copier.object;
+package software.xdev.spring.data.eclipse.store.repository.support.copier.registering;
import java.util.HashMap;
import java.util.Map;
-import org.eclipse.serializer.Serializer;
-import org.eclipse.serializer.SerializerFoundation;
-import org.eclipse.serializer.persistence.binary.jdk17.java.util.BinaryHandlerImmutableCollectionsList12;
-import org.eclipse.serializer.persistence.binary.jdk17.java.util.BinaryHandlerImmutableCollectionsSet12;
import org.eclipse.serializer.persistence.binary.types.Binary;
import org.eclipse.serializer.persistence.binary.types.BinaryStorer;
import org.eclipse.serializer.persistence.types.PersistenceLoader;
import org.eclipse.serializer.persistence.types.PersistenceManager;
import org.eclipse.serializer.persistence.types.PersistenceStorer;
-import org.eclipse.serializer.reference.Reference;
-import org.eclipse.serializer.util.X;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import software.xdev.spring.data.eclipse.store.exceptions.DataTypeNotSupportedException;
import software.xdev.spring.data.eclipse.store.repository.SupportedChecker;
-import software.xdev.spring.data.eclipse.store.repository.WorkingCopyRegistry;
import software.xdev.spring.data.eclipse.store.repository.support.copier.DataTypeUtil;
@@ -42,32 +35,23 @@
* This class utilizes EclipseStore-Serialization and copies objects by serializing and deserializing objects in
* memory.
*/
-public class EclipseSerializerRegisteringCopier implements RegisteringObjectCopier
+public class EclipseSerializerRegisteringCopier implements AutoCloseable
{
private static final Logger LOG = LoggerFactory.getLogger(EclipseSerializerRegisteringCopier.class);
- private final SerializerFoundation> foundation;
private PersistenceManager persistenceManager;
private final SupportedChecker supportedChecker;
-
- private final WorkingCopyRegistry registry;
+ private final RegisteringWorkingCopyAndOriginal register;
public EclipseSerializerRegisteringCopier(
- final WorkingCopyRegistry registry,
- final SupportedChecker supportedChecker)
+ final SupportedChecker supportedChecker,
+ final RegisteringWorkingCopyAndOriginal register,
+ final PersistenceManager persistenceManager)
{
- final SerializerFoundation> newFoundation = SerializerFoundation.New();
- newFoundation.registerCustomTypeHandler(BinaryHandlerImmutableCollectionsSet12.New());
- newFoundation.registerCustomTypeHandler(BinaryHandlerImmutableCollectionsList12.New());
- this.foundation = newFoundation;
- this.registry = registry;
this.supportedChecker = supportedChecker;
+ this.register = register;
+ this.persistenceManager = persistenceManager;
}
-
- @Override
- public synchronized T copy(final T source)
- {
- return this.copy(source, false);
- }
+
@Override
public synchronized void close()
@@ -80,28 +64,6 @@ public synchronized void close()
}
}
- private void lazyInit()
- {
- if(this.persistenceManager == null)
- {
- final Reference buffer = X.Reference(null);
- final Serializer.Source source = () -> X.Constant(buffer.get());
- final Serializer.Target target = buffer::set;
- this.persistenceManager =
- (((SerializerFoundation>)this.foundation.setPersistenceSource(source))
- .setPersistenceTarget(target))
- // Make every type persistable.
- // This is quite dangerous!
- // But if this is not set we get problems e.g. with HashMap$Node
- .setTypeEvaluatorPersistable(a -> true)
- .createPersistenceManager();
- }
- else
- {
- this.persistenceManager.objectRegistry().truncateAll();
- }
- }
-
/**
* Here lies a lot of knowledge about EclipseStore internals.
*
@@ -116,11 +78,9 @@ private void lazyInit()
* EclipseStore-ObjectId.
*
*/
- @SuppressWarnings("unchecked")
- @Override
- public synchronized T copy(final T source, final boolean invertRegistering)
+ public synchronized T copy(final T source)
{
- this.lazyInit();
+ this.persistenceManager.objectRegistry().truncateAll();
final BinaryStorer.Default storer = (BinaryStorer.Default)this.persistenceManager.createStorer();
// Loader erstellen
final PersistenceLoader loader = this.persistenceManager.createLoader();
@@ -153,14 +113,7 @@ public synchronized T copy(final T source, final boolean invertRegistering)
if(originalObject != null)
{
summarizer.incrementRegisteredObjectsCount();
- if(invertRegistering)
- {
- this.registry.invertRegister(copiedObject, originalObject);
- }
- else
- {
- this.registry.register(copiedObject, originalObject);
- }
+ this.register.register(copiedObject, originalObject);
}
}
);
diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/object/RegisteringObjectCopier.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/registering/RegisteringObjectCopier.java
similarity index 73%
rename from spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/object/RegisteringObjectCopier.java
rename to spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/registering/RegisteringObjectCopier.java
index 4e659c08..146cd700 100644
--- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/object/RegisteringObjectCopier.java
+++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/registering/RegisteringObjectCopier.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,12 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package software.xdev.spring.data.eclipse.store.repository.support.copier.object;
+package software.xdev.spring.data.eclipse.store.repository.support.copier.registering;
-import org.eclipse.serializer.ObjectCopier;
-
-
-public interface RegisteringObjectCopier extends ObjectCopier
+public interface RegisteringObjectCopier extends AutoCloseable
{
- T copy(T t, boolean invertRegistering);
+ T copy(T t);
}
diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/registering/RegisteringStorageToWorkingCopyCopier.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/registering/RegisteringStorageToWorkingCopyCopier.java
new file mode 100644
index 00000000..df11886e
--- /dev/null
+++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/registering/RegisteringStorageToWorkingCopyCopier.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright © 2024 XDEV Software (https://xdev.software)
+ *
+ * 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
+ *
+ * http://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.repository.support.copier.registering;
+
+import org.eclipse.serializer.reference.ObjectSwizzling;
+
+import software.xdev.spring.data.eclipse.store.repository.SupportedChecker;
+import software.xdev.spring.data.eclipse.store.repository.WorkingCopyRegistry;
+import software.xdev.spring.data.eclipse.store.repository.support.copier.working.WorkingCopier;
+
+
+/**
+ * This class registers storage instances and copy them for working copies. Utilizes
+ * {@link EclipseSerializerRegisteringCopier}.
+ */
+public class RegisteringStorageToWorkingCopyCopier extends AbstractRegisteringCopier
+{
+ public RegisteringStorageToWorkingCopyCopier(
+ final WorkingCopyRegistry registry,
+ final SupportedChecker supportedChecker,
+ final ObjectSwizzling objectSwizzling,
+ final WorkingCopier> copier)
+ {
+ super(
+ supportedChecker,
+ registry::register,
+ objectSwizzling,
+ copier
+ );
+ }
+}
diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/registering/RegisteringWorkingCopyAndOriginal.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/registering/RegisteringWorkingCopyAndOriginal.java
new file mode 100644
index 00000000..3a9ca24d
--- /dev/null
+++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/registering/RegisteringWorkingCopyAndOriginal.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright © 2024 XDEV Software (https://xdev.software)
+ *
+ * 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
+ *
+ * http://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.repository.support.copier.registering;
+
+@FunctionalInterface
+public interface RegisteringWorkingCopyAndOriginal
+{
+ boolean register(final Object workingCopy, final Object objectToStore);
+}
diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/registering/RegisteringWorkingCopyToStorageCopier.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/registering/RegisteringWorkingCopyToStorageCopier.java
new file mode 100644
index 00000000..9fdc45f7
--- /dev/null
+++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/registering/RegisteringWorkingCopyToStorageCopier.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright © 2024 XDEV Software (https://xdev.software)
+ *
+ * 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
+ *
+ * http://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.repository.support.copier.registering;
+
+import org.eclipse.serializer.reference.ObjectSwizzling;
+
+import software.xdev.spring.data.eclipse.store.repository.SupportedChecker;
+import software.xdev.spring.data.eclipse.store.repository.WorkingCopyRegistry;
+import software.xdev.spring.data.eclipse.store.repository.support.copier.working.WorkingCopier;
+
+
+/**
+ * This class registers working copy instances and copy them for the storage. Utilizes
+ * {@link EclipseSerializerRegisteringCopier}.
+ */
+public class RegisteringWorkingCopyToStorageCopier extends AbstractRegisteringCopier
+{
+
+ public RegisteringWorkingCopyToStorageCopier(
+ final WorkingCopyRegistry registry,
+ final SupportedChecker supportedChecker,
+ final ObjectSwizzling objectSwizzling,
+ final WorkingCopier> copier)
+ {
+ super(
+ supportedChecker,
+ registry::invertRegister,
+ objectSwizzling,
+ copier
+ );
+ }
+}
diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/working/ChangedObjectCollector.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/working/ChangedObjectCollector.java
index d1cd9f5b..c3461f20 100644
--- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/working/ChangedObjectCollector.java
+++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/working/ChangedObjectCollector.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/working/HashSetChangedObjectCollector.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/working/HashSetChangedObjectCollector.java
index dc9fad70..fd3f31b1 100644
--- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/working/HashSetChangedObjectCollector.java
+++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/working/HashSetChangedObjectCollector.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/working/HashSetMergedTargetsCollector.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/working/HashSetMergedTargetsCollector.java
index 4e1c7cbc..3569e548 100644
--- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/working/HashSetMergedTargetsCollector.java
+++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/working/HashSetMergedTargetsCollector.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/working/MergedTargetsCollector.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/working/MergedTargetsCollector.java
index 86112646..4efaa8ad 100644
--- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/working/MergedTargetsCollector.java
+++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/working/MergedTargetsCollector.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/working/RecursiveWorkingCopier.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/working/RecursiveWorkingCopier.java
index a781da27..c03949fa 100644
--- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/working/RecursiveWorkingCopier.java
+++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/working/RecursiveWorkingCopier.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,6 +27,8 @@
import java.util.TreeMap;
import java.util.TreeSet;
+import org.eclipse.serializer.reference.Lazy;
+import org.eclipse.serializer.reference.ObjectSwizzling;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -37,9 +39,11 @@
import software.xdev.spring.data.eclipse.store.repository.WorkingCopyRegistry;
import software.xdev.spring.data.eclipse.store.repository.access.AccessHelper;
import software.xdev.spring.data.eclipse.store.repository.access.modifier.FieldAccessModifier;
+import software.xdev.spring.data.eclipse.store.repository.lazy.SpringDataEclipseStoreLazy;
import software.xdev.spring.data.eclipse.store.repository.support.copier.DataTypeUtil;
-import software.xdev.spring.data.eclipse.store.repository.support.copier.object.EclipseSerializerRegisteringCopier;
-import software.xdev.spring.data.eclipse.store.repository.support.copier.object.RegisteringObjectCopier;
+import software.xdev.spring.data.eclipse.store.repository.support.copier.registering.RegisteringObjectCopier;
+import software.xdev.spring.data.eclipse.store.repository.support.copier.registering.RegisteringStorageToWorkingCopyCopier;
+import software.xdev.spring.data.eclipse.store.repository.support.copier.registering.RegisteringWorkingCopyToStorageCopier;
/**
@@ -48,7 +52,8 @@
public class RecursiveWorkingCopier implements WorkingCopier
{
private static final Logger LOG = LoggerFactory.getLogger(RecursiveWorkingCopier.class);
- private final RegisteringObjectCopier objectCopier;
+ private final RegisteringObjectCopier workingCopyToStorageCopier;
+ private final RegisteringObjectCopier storageToWorkingCopyCopier;
private final WorkingCopyRegistry registry;
private final IdSetterProvider idSetterProvider;
private final Class domainClass;
@@ -59,11 +64,15 @@ public RecursiveWorkingCopier(
final WorkingCopyRegistry registry,
final IdSetterProvider idSetterProvider,
final PersistableChecker persistableChecker,
- final SupportedChecker supportedChecker)
+ final SupportedChecker supportedChecker,
+ final ObjectSwizzling objectSwizzling)
{
this.domainClass = domainClass;
this.registry = registry;
- this.objectCopier = new EclipseSerializerRegisteringCopier(registry, supportedChecker);
+ this.workingCopyToStorageCopier =
+ new RegisteringWorkingCopyToStorageCopier(registry, supportedChecker, objectSwizzling, this);
+ this.storageToWorkingCopyCopier =
+ new RegisteringStorageToWorkingCopyCopier(registry, supportedChecker, objectSwizzling, this);
this.idSetterProvider = idSetterProvider;
this.persistableChecker = persistableChecker;
}
@@ -144,7 +153,7 @@ public E getOrCreateObjectForDatastore(
// The object to merge back is not a working copy, but a originalObject.
// Therefore, we create a copy to persist this in the storage.
final E objectForDatastore = this.genericCopy(workingCopy, true);
- // "Why merging values of an identical object?" you might ask.
+ // "Why merge values of an identical object?" you might ask.
// Well, because some sub-objects might already be in the datastore.
this.mergeValues(workingCopy, objectForDatastore, alreadyMergedTargets, changedCollector);
changedCollector.collectChangedObject(objectForDatastore);
@@ -161,7 +170,8 @@ private void mergeValues(
final E sourceObject,
final E targetObject,
final MergedTargetsCollector alreadyMergedTargets,
- final ChangedObjectCollector changedCollector)
+ final ChangedObjectCollector changedCollector
+ )
{
if(sourceObject == targetObject || alreadyMergedTargets.isAlreadyMerged(targetObject) || targetObject == null)
{
@@ -172,14 +182,21 @@ private void mergeValues(
{
alreadyMergedTargets.collectMergedTarget(targetObject);
- if(sourceObject instanceof String)
+ if(sourceObject instanceof String || sourceObject instanceof SpringDataEclipseStoreLazy>)
{
// no merge needed and no merge possible
return;
}
- AccessHelper.getInheritedPrivateFieldsByName(sourceObject.getClass()).values().forEach(
+ final Collection valuesToMerge =
+ AccessHelper.getInheritedPrivateFieldsByName(sourceObject.getClass()).values();
+ valuesToMerge.forEach(
field ->
- this.mergeValueOfField(sourceObject, targetObject, field, alreadyMergedTargets, changedCollector)
+ this.mergeValueOfField(
+ sourceObject,
+ targetObject,
+ field,
+ alreadyMergedTargets,
+ changedCollector)
);
}
catch(final Exception e)
@@ -203,7 +220,7 @@ private void mergeValueOfField(
return;
}
- try(final FieldAccessModifier fam = FieldAccessModifier.makeFieldReadable(
+ try(final FieldAccessModifier fam = FieldAccessModifier.prepareForField(
field,
sourceObject))
{
@@ -243,41 +260,28 @@ else if(DataTypeUtil.isObjectArray(valueOfSourceObject))
);
fam.writeValueOfField(targetObject, newArray, !targetObjectIsPartOfJavaPackage);
}
+ else if(DataTypeUtil.isSpringDataEclipseStoreLazy(valueOfSourceObject))
+ {
+ final SpringDataEclipseStoreLazy> newLazy =
+ this.createNewLazy(
+ (SpringDataEclipseStoreLazy>)valueOfSourceObject,
+ (SpringDataEclipseStoreLazy>)valueOfTargetObject,
+ alreadyMergedTargets,
+ changedCollector);
+ fam.writeValueOfField(targetObject, newLazy, true);
+ }
else
{
// "Simple" object
// get original value object
- final Object originalValueObjectOfSource =
- this.getOrCreateObjectForDatastore(
- valueOfSourceObject,
- false,
- alreadyMergedTargets,
- changedCollector);
- if(valueOfTargetObject != originalValueObjectOfSource)
- {
- // If the reference is new, it must be set
- fam.writeValueOfField(
- targetObject,
- originalValueObjectOfSource,
- !targetObjectIsPartOfJavaPackage);
- }
-
- if(this.isSpecialCaseWhereOnlyAFullCopyWorks(valueOfSourceObject))
- {
- fam.writeValueOfField(
- targetObject,
- this.onlyCreateCopy(valueOfSourceObject, true),
- !targetObjectIsPartOfJavaPackage);
- }
- else
- {
- // Merge after setting reference to avoid endless loops
- this.mergeValues(
- valueOfSourceObject,
- originalValueObjectOfSource,
- alreadyMergedTargets,
- changedCollector);
- }
+ this.mergeSimpleObjectValue(
+ targetObject,
+ alreadyMergedTargets,
+ changedCollector,
+ valueOfSourceObject,
+ valueOfTargetObject,
+ fam,
+ targetObjectIsPartOfJavaPackage);
}
}
}
@@ -288,6 +292,99 @@ else if(DataTypeUtil.isObjectArray(valueOfSourceObject))
}
}
+ private void mergeSimpleObjectValue(
+ final E targetObject,
+ final MergedTargetsCollector alreadyMergedTargets,
+ final ChangedObjectCollector changedCollector,
+ final Object valueOfSourceObject,
+ final Object valueOfTargetObject,
+ final FieldAccessModifier fam,
+ final boolean targetObjectIsPartOfJavaPackage) throws IllegalAccessException
+ {
+ final Object originalValueObjectOfSource =
+ this.getOrCreateObjectForDatastore(
+ valueOfSourceObject,
+ false,
+ alreadyMergedTargets,
+ changedCollector);
+ if(valueOfTargetObject != originalValueObjectOfSource)
+ {
+ // If the reference is new, it must be set
+ fam.writeValueOfField(
+ targetObject,
+ originalValueObjectOfSource,
+ !targetObjectIsPartOfJavaPackage);
+ }
+
+ if(this.isSpecialCaseWhereOnlyAFullCopyWorks(valueOfSourceObject))
+ {
+ fam.writeValueOfField(
+ targetObject,
+ this.onlyCreateCopy(valueOfSourceObject, true),
+ !targetObjectIsPartOfJavaPackage);
+ }
+ else
+ {
+ // Merge after setting reference to avoid endless loops
+ this.mergeValues(
+ valueOfSourceObject,
+ originalValueObjectOfSource,
+ alreadyMergedTargets,
+ changedCollector);
+ }
+ }
+
+ private SpringDataEclipseStoreLazy createNewLazy(
+ final SpringDataEclipseStoreLazy oldLazy,
+ final SpringDataEclipseStoreLazy> newLazy,
+ final MergedTargetsCollector alreadyMergedTargets,
+ final ChangedObjectCollector changedCollector
+ )
+ {
+ if(oldLazy.isLoaded())
+ {
+ if(oldLazy.isOriginalObject())
+ {
+ // This object is new and in this case it is merged into the storage.
+ if(!newLazy.isStored())
+ {
+ // The EclipseSerializerRegisteringCopier already creates the perfect lazy object.
+ // No change necessary.
+ return (SpringDataEclipseStoreLazy)newLazy;
+ }
+ else
+ {
+ // This object is already stored but the new version must get overwritten.
+ // The oldLazy Object can contain all kinds of objects (including more lazies)
+ final E copyOfWrappedObject = this.getOrCreateObjectForDatastore(
+ oldLazy.get(),
+ true,
+ alreadyMergedTargets,
+ changedCollector);
+ oldLazy.unlink();
+ newLazy.unlink();
+
+ return SpringDataEclipseStoreLazy.Internals.buildWithLazy(Lazy.Reference(copyOfWrappedObject));
+ }
+ }
+ final E copyOfWrappedObject = this.getOrCreateObjectForDatastore(
+ oldLazy.get(),
+ true,
+ alreadyMergedTargets,
+ changedCollector);
+ oldLazy.unlink();
+ newLazy.unlink();
+ return SpringDataEclipseStoreLazy.build(copyOfWrappedObject);
+ }
+ else
+ {
+ oldLazy.unlink();
+ // This lazy should never be used again!
+ // It is though of as a temporary copy to merge back into the original-storage-data.
+ return (SpringDataEclipseStoreLazy)newLazy.copyWithReference();
+ }
+ }
+
/**
* Super special case for HashMap or similar java-classes which can't be merged nicely. Thus, we make a simple copy
* of the whole object.
@@ -326,9 +423,14 @@ private E[] createGenericObjectArray(
return newArray;
}
- private E onlyCreateCopy(final E objectToCopy, final boolean invertRegistry)
+ @Override
+ public E onlyCreateCopy(final E objectToCopy, final boolean invertRegistry)
{
- return this.objectCopier.copy(objectToCopy, invertRegistry);
+ if(invertRegistry)
+ {
+ return this.workingCopyToStorageCopier.copy(objectToCopy);
+ }
+ return this.storageToWorkingCopyCopier.copy(objectToCopy);
}
@Override
diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/working/WorkingCopier.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/working/WorkingCopier.java
index c2c60f23..fdf84e73 100644
--- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/working/WorkingCopier.java
+++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/working/WorkingCopier.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -50,6 +50,8 @@ public interface WorkingCopier
*/
WorkingCopierResult mergeBack(T workingCopy);
+ E onlyCreateCopy(final E objectToCopy, final boolean invertRegistry);
+
/**
* @return the original entity that corresponds to the given working copy object.
*/
diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/working/WorkingCopierCreator.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/working/WorkingCopierCreator.java
index e5415938..4f0a50a8 100644
--- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/working/WorkingCopierCreator.java
+++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/working/WorkingCopierCreator.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/working/WorkingCopierResult.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/working/WorkingCopierResult.java
index b780b2da..c88bc711 100644
--- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/working/WorkingCopierResult.java
+++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/working/WorkingCopierResult.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/reposyncer/RepositorySynchronizer.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/reposyncer/RepositorySynchronizer.java
index b071aae5..399552a2 100644
--- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/reposyncer/RepositorySynchronizer.java
+++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/reposyncer/RepositorySynchronizer.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/reposyncer/SimpleRepositorySynchronizer.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/reposyncer/SimpleRepositorySynchronizer.java
index 644b4fa8..5b812d77 100644
--- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/reposyncer/SimpleRepositorySynchronizer.java
+++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/reposyncer/SimpleRepositorySynchronizer.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/util/GenericObjectComparer.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/util/GenericObjectComparer.java
index 22bf49b3..633f6544 100644
--- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/util/GenericObjectComparer.java
+++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/util/GenericObjectComparer.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/util/StringUtil.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/util/StringUtil.java
index bcf1a600..8bea8d55 100644
--- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/util/StringUtil.java
+++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/util/StringUtil.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/helper/DummyWorkingCopier.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/helper/DummyWorkingCopier.java
index e92deeb6..d07d0627 100644
--- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/helper/DummyWorkingCopier.java
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/helper/DummyWorkingCopier.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -41,6 +41,12 @@ public WorkingCopierResult mergeBack(final T workingCopy)
return null;
}
+ @Override
+ public E onlyCreateCopy(final E objectToCopy, final boolean invertRegistry)
+ {
+ return objectToCopy;
+ }
+
@Override
public T getOriginal(final T workingCopy)
{
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/helper/StorageDirectoryNameProvider.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/helper/StorageDirectoryNameProvider.java
new file mode 100644
index 00000000..2813f208
--- /dev/null
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/helper/StorageDirectoryNameProvider.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright © 2024 XDEV Software (https://xdev.software)
+ *
+ * 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
+ *
+ * http://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.helper;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+
+public final class StorageDirectoryNameProvider
+{
+ private static final AtomicInteger SEQ_NUMBER = new AtomicInteger(1);
+
+ private StorageDirectoryNameProvider()
+ {
+ }
+
+ public static String getNewStorageDirectoryPath()
+ {
+ return String.format("./target/tempstorage-%05d", SEQ_NUMBER.getAndIncrement());
+ }
+}
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/helper/TestData.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/helper/TestData.java
index e5482b6d..683d5e69 100644
--- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/helper/TestData.java
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/helper/TestData.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,6 +22,9 @@ public final class TestData
public static final String LAST_NAME_ALTERNATIVE = "Nicks";
public static final String FIRST_NAME_ALTERNATIVE = "Stevie";
+ public static final String DUMMY_STRING = "-- skldfoöüä+#+!(/%&/%($§\"=)()nxjkß? _:.. ,-.;";
+ public static final String DUMMY_STRING_ALTERNATIVE = " abc ";
+
private TestData()
{
}
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/helper/TestUtil.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/helper/TestUtil.java
index 98cb7550..dcfc4e77 100644
--- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/helper/TestUtil.java
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/helper/TestUtil.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@
import org.opentest4j.AssertionFailedError;
-import software.xdev.spring.data.eclipse.store.repository.EclipseStoreStorage;
+import software.xdev.spring.data.eclipse.store.repository.config.EclipseStoreClientConfiguration;
public final class TestUtil
@@ -32,14 +32,14 @@ public static List iterableToList(final Iterable iterable)
return list;
}
- public static void restartDatastore(final EclipseStoreStorage storage)
+ public static void restartDatastore(final EclipseStoreClientConfiguration configuration)
{
- storage.stop();
+ configuration.getStorageInstance().stop();
// Storage starts automatically again, if the repo is accessed
}
public static void doBeforeAndAfterRestartOfDatastore(
- final EclipseStoreStorage storage,
+ final EclipseStoreClientConfiguration configuration,
final Runnable thingToDoBeforeAndAfterRestart)
{
try
@@ -50,7 +50,7 @@ public static void doBeforeAndAfterRestartOfDatastore(
{
throw new AssertionFailedError("Error before restart of storage", error);
}
- restartDatastore(storage);
+ restartDatastore(configuration);
try
{
thingToDoBeforeAndAfterRestart.run();
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/TestConfiguration.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/TestConfiguration.java
index 5c0ea1fa..3f6557fd 100644
--- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/TestConfiguration.java
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/TestConfiguration.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,43 +15,47 @@
*/
package software.xdev.spring.data.eclipse.store.integration;
+import static org.eclipse.store.storage.embedded.types.EmbeddedStorage.Foundation;
+
+import java.io.IOException;
import java.nio.file.Path;
-import org.springframework.beans.factory.DisposableBean;
-import org.springframework.beans.factory.annotation.Value;
+import org.eclipse.store.storage.embedded.types.EmbeddedStorageFoundation;
+import org.eclipse.store.storage.types.Storage;
import org.springframework.context.annotation.Configuration;
+import org.springframework.context.event.ContextClosedEvent;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.context.event.EventListener;
import org.springframework.util.FileSystemUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import software.xdev.spring.data.eclipse.store.repository.EclipseStoreStorage;
-import software.xdev.spring.data.eclipse.store.repository.config.EnableEclipseStoreRepositories;
+import software.xdev.spring.data.eclipse.store.helper.StorageDirectoryNameProvider;
+import software.xdev.spring.data.eclipse.store.repository.config.EclipseStoreClientConfiguration;
@Configuration
-@EnableEclipseStoreRepositories
-public class TestConfiguration implements DisposableBean
+public class TestConfiguration extends EclipseStoreClientConfiguration
{
- @Autowired
- EclipseStoreStorage storage;
+ private final String storageDirectory = StorageDirectoryNameProvider.getNewStorageDirectoryPath();
- @Value("${org.eclipse.store.storage-directory}")
- private String storageDirectory;
+ @Override
+ public EmbeddedStorageFoundation> createEmbeddedStorageFoundation()
+ {
+ return Foundation(Storage.Configuration(Storage.FileProvider(Path.of(this.storageDirectory))));
+ }
@EventListener
public void handleContextRefresh(final ContextRefreshedEvent event)
{
// Init with empty root object
- this.storage.clearData();
+ this.getStorageInstance().clearData();
}
- @Override
- public void destroy() throws Exception
+ @EventListener
+ public void handleContextClosed(final ContextClosedEvent event) throws IOException
{
// End with empty root object
- this.storage.clearData();
- this.storage.stop();
+ this.getStorageInstance().clearData();
+ this.getStorageInstance().stop();
FileSystemUtils.deleteRecursively(Path.of(this.storageDirectory));
}
}
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/IsolatedTestAnnotations.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/IsolatedTestAnnotations.java
similarity index 86%
rename from spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/IsolatedTestAnnotations.java
rename to spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/IsolatedTestAnnotations.java
index 61d27ef1..164c75e1 100644
--- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/IsolatedTestAnnotations.java
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/IsolatedTestAnnotations.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package software.xdev.spring.data.eclipse.store.integration.isolated.tests;
+package software.xdev.spring.data.eclipse.store.integration.isolated;
import static org.springframework.test.annotation.DirtiesContext.ClassMode.BEFORE_EACH_TEST_METHOD;
@@ -24,14 +24,12 @@
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.test.annotation.DirtiesContext;
-import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@ExtendWith(SpringExtension.class)
-@ContextConfiguration(classes = {IsolatedTestConfiguration.class})
@DirtiesContext(classMode = BEFORE_EACH_TEST_METHOD)
public @interface IsolatedTestAnnotations
{
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/package-info.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/package-info.java
new file mode 100644
index 00000000..917d49c7
--- /dev/null
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright © 2024 XDEV Software (https://xdev.software)
+ *
+ * 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
+ *
+ * http://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.
+ */
+/**
+ * The repositories of these tests are seperated from each other. That means that e.g. the
+ * {@link software.xdev.spring.data.eclipse.store.integration.isolated.tests.special.types.TypesTest} can't access the
+ * {@link software.xdev.spring.data.eclipse.store.integration.isolated.tests.keywords.MinimalRepository}.
+ */
+package software.xdev.spring.data.eclipse.store.integration.isolated;
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/IsolatedTestConfiguration.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/IsolatedTestConfiguration.java
deleted file mode 100644
index a5be2ce0..00000000
--- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/IsolatedTestConfiguration.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
- *
- * 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
- *
- * http://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.integration.isolated.tests;
-
-import java.nio.file.Path;
-
-import org.springframework.beans.factory.DisposableBean;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.event.ContextRefreshedEvent;
-import org.springframework.context.event.EventListener;
-import org.springframework.util.FileSystemUtils;
-
-import software.xdev.spring.data.eclipse.store.repository.EclipseStoreStorage;
-import software.xdev.spring.data.eclipse.store.repository.config.EnableEclipseStoreRepositories;
-
-
-@Configuration
-@EnableEclipseStoreRepositories
-public class IsolatedTestConfiguration implements DisposableBean
-{
- @Autowired
- EclipseStoreStorage storage;
-
- @Value("${org.eclipse.store.storage-directory}")
- private String storageDirectory;
-
- @EventListener
- public void handleContextRefresh(final ContextRefreshedEvent event)
- {
- // Init with empty root object
- this.storage.clearData();
- }
-
- @Override
- public void destroy() throws Exception
- {
- // End with empty root object
- this.storage.clearData();
- this.storage.stop();
- FileSystemUtils.deleteRecursively(Path.of(this.storageDirectory));
- }
-}
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/deletion/DeletionTest.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/deletion/DeletionTest.java
new file mode 100644
index 00000000..da5a3827
--- /dev/null
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/deletion/DeletionTest.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright © 2024 XDEV Software (https://xdev.software)
+ *
+ * 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
+ *
+ * http://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.integration.isolated.tests.deletion;
+
+import java.util.List;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+
+import software.xdev.spring.data.eclipse.store.helper.TestUtil;
+import software.xdev.spring.data.eclipse.store.integration.isolated.IsolatedTestAnnotations;
+
+
+/**
+ * These tests should show that all or most of the following keywords are available in this library: Repository query
+ * keywords
+ */
+@IsolatedTestAnnotations
+@ContextConfiguration(classes = {DeletionTestConfiguration.class})
+class DeletionTest
+{
+ @Autowired
+ private DeletionTestConfiguration configuration;
+
+ @Test
+ void deleteReferencedObject(
+ @Autowired final ReferencedRepository referencedRepository,
+ @Autowired final ReferencingRepository referencingRepository)
+ {
+ final ReferencedDaoObject referencedObject = new ReferencedDaoObject("someValue");
+ final ReferencingDaoObject referencingDaoObject = new ReferencingDaoObject(referencedObject);
+ referencingRepository.save(referencingDaoObject);
+
+ Assertions.assertEquals(1, TestUtil.iterableToList(referencingRepository.findAll()).size());
+ Assertions.assertEquals(1, TestUtil.iterableToList(referencedRepository.findAll()).size());
+
+ referencedRepository.delete(referencedObject);
+
+ TestUtil.doBeforeAndAfterRestartOfDatastore(
+ this.configuration,
+ () -> {
+ Assertions.assertTrue(TestUtil.iterableToList(referencedRepository.findAll()).isEmpty());
+ final List referencingDaoObjects =
+ TestUtil.iterableToList(referencingRepository.findAll());
+ Assertions.assertEquals(1, referencingDaoObjects.size());
+ Assertions.assertNotNull(referencingDaoObjects.get(0).getValue());
+ }
+ );
+ }
+
+ @Test
+ void restoreDeletedReferencedObject(
+ @Autowired final ReferencedRepository referencedRepository,
+ @Autowired final ReferencingRepository referencingRepository)
+ {
+ final ReferencedDaoObject referencedObject = new ReferencedDaoObject("someValue");
+ final ReferencingDaoObject referencingDaoObject = new ReferencingDaoObject(referencedObject);
+
+ referencingRepository.save(referencingDaoObject);
+ referencedRepository.delete(referencedObject);
+ referencingRepository.save(referencingDaoObject);
+
+ TestUtil.doBeforeAndAfterRestartOfDatastore(
+ this.configuration,
+ () -> {
+ Assertions.assertEquals(1, TestUtil.iterableToList(referencingRepository.findAll()).size());
+ Assertions.assertEquals(1, TestUtil.iterableToList(referencedRepository.findAll()).size());
+ }
+ );
+ }
+}
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/deletion/DeletionTestConfiguration.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/deletion/DeletionTestConfiguration.java
new file mode 100644
index 00000000..0db7c903
--- /dev/null
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/deletion/DeletionTestConfiguration.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright © 2024 XDEV Software (https://xdev.software)
+ *
+ * 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
+ *
+ * http://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.integration.isolated.tests.deletion;
+
+import org.springframework.context.annotation.Configuration;
+
+import software.xdev.spring.data.eclipse.store.integration.TestConfiguration;
+import software.xdev.spring.data.eclipse.store.repository.config.EnableEclipseStoreRepositories;
+
+
+@Configuration
+@EnableEclipseStoreRepositories(clientConfigurationClass = DeletionTestConfiguration.class)
+public class DeletionTestConfiguration extends TestConfiguration
+{
+}
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/deletion/ReferencedDaoObject.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/deletion/ReferencedDaoObject.java
new file mode 100644
index 00000000..94577218
--- /dev/null
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/deletion/ReferencedDaoObject.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright © 2024 XDEV Software (https://xdev.software)
+ *
+ * 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
+ *
+ * http://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.integration.isolated.tests.deletion;
+
+public class ReferencedDaoObject
+{
+ private String value;
+
+ public ReferencedDaoObject(final String value)
+ {
+ this.value = value;
+ }
+
+ public String getValue()
+ {
+ return this.value;
+ }
+
+ public void setValue(final String value)
+ {
+ this.value = value;
+ }
+}
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/deletion/ReferencedRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/deletion/ReferencedRepository.java
new file mode 100644
index 00000000..7cc76772
--- /dev/null
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/deletion/ReferencedRepository.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright © 2024 XDEV Software (https://xdev.software)
+ *
+ * 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
+ *
+ * http://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.integration.isolated.tests.deletion;
+
+import org.springframework.data.repository.CrudRepository;
+
+
+public interface ReferencedRepository extends CrudRepository
+{
+}
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/deletion/ReferencingDaoObject.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/deletion/ReferencingDaoObject.java
new file mode 100644
index 00000000..15d4cf5a
--- /dev/null
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/deletion/ReferencingDaoObject.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright © 2024 XDEV Software (https://xdev.software)
+ *
+ * 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
+ *
+ * http://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.integration.isolated.tests.deletion;
+
+public class ReferencingDaoObject
+{
+ private ReferencedDaoObject value;
+
+ public ReferencingDaoObject(final ReferencedDaoObject value)
+ {
+ this.value = value;
+ }
+
+ public ReferencedDaoObject getValue()
+ {
+ return this.value;
+ }
+
+ public void setValue(final ReferencedDaoObject value)
+ {
+ this.value = value;
+ }
+}
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/deletion/ReferencingRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/deletion/ReferencingRepository.java
new file mode 100644
index 00000000..f89a1885
--- /dev/null
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/deletion/ReferencingRepository.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright © 2024 XDEV Software (https://xdev.software)
+ *
+ * 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
+ *
+ * http://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.integration.isolated.tests.deletion;
+
+import org.springframework.data.repository.CrudRepository;
+
+
+public interface ReferencingRepository extends CrudRepository
+{
+}
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/keywords/KeywordsTest.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/keywords/KeywordsTest.java
index 61c012ca..e4e09179 100644
--- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/keywords/KeywordsTest.java
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/keywords/KeywordsTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,11 +19,10 @@
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.context.TestPropertySource;
+import org.springframework.test.context.ContextConfiguration;
import software.xdev.spring.data.eclipse.store.helper.TestUtil;
-import software.xdev.spring.data.eclipse.store.integration.isolated.tests.IsolatedTestAnnotations;
-import software.xdev.spring.data.eclipse.store.repository.EclipseStoreStorage;
+import software.xdev.spring.data.eclipse.store.integration.isolated.IsolatedTestAnnotations;
/**
@@ -32,14 +31,11 @@
* keywords
*/
@IsolatedTestAnnotations
-@TestPropertySource(
- properties =
- "org.eclipse.store.storage-directory=./target/keywords-tests-storage"
-)
+@ContextConfiguration(classes = {KeywordsTestConfiguration.class})
class KeywordsTest
{
@Autowired
- private EclipseStoreStorage storage;
+ private KeywordsTestConfiguration configuration;
@Test
@Disabled("For now we don't need 'existsBy'")
@@ -48,7 +44,7 @@ void simpleStoreAndRead(final MinimalRepository repository)
repository.save(new MinimalDaoObject("1"));
TestUtil.doBeforeAndAfterRestartOfDatastore(
- this.storage,
+ this.configuration,
() -> {
Assertions.assertTrue(repository.existsByValue("1"));
Assertions.assertFalse(repository.existsByValue("2"));
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/keywords/KeywordsTestConfiguration.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/keywords/KeywordsTestConfiguration.java
new file mode 100644
index 00000000..6c3d3a65
--- /dev/null
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/keywords/KeywordsTestConfiguration.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright © 2024 XDEV Software (https://xdev.software)
+ *
+ * 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
+ *
+ * http://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.integration.isolated.tests.keywords;
+
+import org.springframework.context.annotation.Configuration;
+
+import software.xdev.spring.data.eclipse.store.integration.TestConfiguration;
+import software.xdev.spring.data.eclipse.store.repository.config.EnableEclipseStoreRepositories;
+
+
+@Configuration
+@EnableEclipseStoreRepositories(clientConfigurationClass = KeywordsTestConfiguration.class)
+public class KeywordsTestConfiguration extends TestConfiguration
+{
+}
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/keywords/MinimalDaoObject.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/keywords/MinimalDaoObject.java
index f306c867..c7c52c70 100644
--- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/keywords/MinimalDaoObject.java
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/keywords/MinimalDaoObject.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/keywords/MinimalRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/keywords/MinimalRepository.java
index c1db0a3f..534c042b 100644
--- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/keywords/MinimalRepository.java
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/keywords/MinimalRepository.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/ComplexLazyObject.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/ComplexLazyObject.java
new file mode 100644
index 00000000..02413a96
--- /dev/null
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/ComplexLazyObject.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright © 2024 XDEV Software (https://xdev.software)
+ *
+ * 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
+ *
+ * http://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.integration.isolated.tests.lazy;
+
+import java.util.List;
+
+import org.eclipse.serializer.reference.Lazy;
+
+
+public class ComplexLazyObject
+{
+ private Lazy simpleObject;
+ private List>> listOfLazyListOfString;
+
+ public ComplexLazyObject(
+ final Lazy simpleObject,
+ final List>> listOfLazyListOfString)
+ {
+ this.simpleObject = simpleObject;
+ this.listOfLazyListOfString = listOfLazyListOfString;
+ }
+
+ public Lazy getSimpleObject()
+ {
+ return this.simpleObject;
+ }
+
+ public void setSimpleObject(final Lazy simpleObject)
+ {
+ this.simpleObject = simpleObject;
+ }
+
+ public List>> getListOfLazyListOfString()
+ {
+ return this.listOfLazyListOfString;
+ }
+
+ public void setListOfLazyListOfString(final List>> listOfLazyListOfString)
+ {
+ this.listOfLazyListOfString = listOfLazyListOfString;
+ }
+}
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/LazyTest.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/LazyTest.java
new file mode 100644
index 00000000..b51c683e
--- /dev/null
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/LazyTest.java
@@ -0,0 +1,468 @@
+/*
+ * Copyright © 2024 XDEV Software (https://xdev.software)
+ *
+ * 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
+ *
+ * http://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.integration.isolated.tests.lazy;
+
+import static software.xdev.spring.data.eclipse.store.helper.TestUtil.restartDatastore;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.serializer.collections.lazy.LazyArrayList;
+import org.eclipse.serializer.collections.lazy.LazyList;
+import org.eclipse.serializer.reference.Lazy;
+import org.eclipse.serializer.reference.LazyReferenceManager;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+
+import software.xdev.spring.data.eclipse.store.helper.TestData;
+import software.xdev.spring.data.eclipse.store.helper.TestUtil;
+import software.xdev.spring.data.eclipse.store.integration.isolated.IsolatedTestAnnotations;
+import software.xdev.spring.data.eclipse.store.repository.lazy.SpringDataEclipseStoreLazy;
+
+
+@IsolatedTestAnnotations
+@ContextConfiguration(classes = {LazyTestConfiguration.class})
+class LazyTest
+{
+ @Autowired
+ private LazyTestConfiguration configuration;
+
+ @Test
+ @Disabled("This should work at some point. At least a warning should be displayed.")
+ void lazyListStore(@Autowired final ObjectWithLazyListRepository repository)
+ {
+ final ObjectWithLazyList newList = new ObjectWithLazyList();
+ final SimpleObject objectToStore = new SimpleObject(TestData.DUMMY_STRING);
+ final LazyArrayList lazyArrayList = new LazyArrayList<>();
+ lazyArrayList.add(objectToStore);
+ newList.setLazyList(lazyArrayList);
+ repository.save(newList);
+
+ TestUtil.doBeforeAndAfterRestartOfDatastore(
+ this.configuration,
+ () -> {
+ Assertions.assertEquals(1, repository.findAll().size());
+ final LazyList loadedLazyList = repository.findAll().get(0).getLazyList();
+ Assertions.assertEquals(1, loadedLazyList.size());
+ Assertions.assertEquals(objectToStore, loadedLazyList.get(0));
+ }
+ );
+ }
+
+ @Test
+ void lazyStore(@Autowired final ObjectWithLazyRepository repository)
+ {
+ final ObjectWithLazy newLazy = new ObjectWithLazy<>();
+ final SimpleObject objectToStore = new SimpleObject(TestData.DUMMY_STRING);
+ newLazy.setLazy(SpringDataEclipseStoreLazy.build(objectToStore));
+ repository.save(newLazy);
+
+ TestUtil.doBeforeAndAfterRestartOfDatastore(
+ this.configuration,
+ () -> {
+ Assertions.assertEquals(1, repository.findAll().size());
+ final Lazy lazy = repository.findAll().get(0).getLazy();
+ Assertions.assertEquals(objectToStore, lazy.get());
+ }
+ );
+ }
+
+ @Test
+ void lazyGetsCleared(@Autowired final ObjectWithLazyRepository repository)
+ {
+ final ObjectWithLazy newLazy = new ObjectWithLazy<>();
+ final SimpleObject objectToStore = new SimpleObject(TestData.DUMMY_STRING);
+ newLazy.setLazy(SpringDataEclipseStoreLazy.build(objectToStore));
+ repository.save(newLazy);
+
+ restartDatastore(this.configuration);
+
+ final List> loadedObjects = repository.findAll();
+ Assertions.assertEquals(1, loadedObjects.size());
+ Assertions.assertFalse(loadedObjects.get(0).getLazy().isLoaded());
+ Assertions.assertNotNull(loadedObjects.get(0).getLazy().get());
+ Assertions.assertTrue(loadedObjects.get(0).getLazy().isLoaded());
+
+ LazyReferenceManager.get().clear();
+ Assertions.assertFalse(repository.findAll().get(0).getLazy().isLoaded());
+ }
+
+ @Test
+ void lazyWorkingCopyIsCreated(@Autowired final ObjectWithLazyRepository repository)
+ {
+ final ObjectWithLazy newLazy = new ObjectWithLazy<>();
+ final SimpleObject objectToStore = new SimpleObject(TestData.DUMMY_STRING);
+ newLazy.setLazy(SpringDataEclipseStoreLazy.build(objectToStore));
+ repository.save(newLazy);
+
+ TestUtil.doBeforeAndAfterRestartOfDatastore(
+ this.configuration,
+ () -> {
+ final SimpleObject storedObject = newLazy.getLazy().get();
+ final SimpleObject loadedObject = repository.findAll().get(0).getLazy().get();
+ Assertions.assertNotSame(storedObject, loadedObject);
+ Assertions.assertEquals(storedObject, loadedObject);
+ }
+ );
+ }
+
+ @Test
+ void lazyDifferentWorkingCopiesAreCreated(@Autowired final ObjectWithLazyRepository repository)
+ {
+ final ObjectWithLazy newLazy = new ObjectWithLazy<>();
+ final SimpleObject objectToStore = new SimpleObject(TestData.DUMMY_STRING);
+ newLazy.setLazy(SpringDataEclipseStoreLazy.build(objectToStore));
+ repository.save(newLazy);
+
+ TestUtil.doBeforeAndAfterRestartOfDatastore(
+ this.configuration,
+ () -> {
+ final ObjectWithLazy workingCopy1 = repository.findAll().get(0);
+ final ObjectWithLazy workingCopy2 = repository.findAll().get(0);
+ Assertions.assertNotSame(workingCopy1.getLazy(), workingCopy2.getLazy());
+ Assertions.assertNotSame(workingCopy1.getLazy().get(), workingCopy2.getLazy().get());
+ Assertions.assertEquals(workingCopy1.getLazy().get(), workingCopy2.getLazy().get());
+ }
+ );
+ }
+
+ @Test
+ void lazyWorkingCopyChange(@Autowired final ObjectWithLazyRepository repository)
+ {
+ final ObjectWithLazy newLazy = new ObjectWithLazy<>();
+ final SimpleObject objectToStore = new SimpleObject(TestData.DUMMY_STRING);
+ newLazy.setLazy(SpringDataEclipseStoreLazy.build(objectToStore));
+ repository.save(newLazy);
+
+ final SimpleObject changedObjectToStore = new SimpleObject(TestData.DUMMY_STRING_ALTERNATIVE);
+ newLazy.setLazy(SpringDataEclipseStoreLazy.build(changedObjectToStore));
+
+ TestUtil.doBeforeAndAfterRestartOfDatastore(
+ this.configuration,
+ () -> {
+ Assertions.assertNotEquals(newLazy.getLazy().get(), repository.findAll().get(0).getLazy().get());
+ }
+ );
+ }
+
+ @Test
+ void lazyWorkingCopyChangeAfterRestart(@Autowired final ObjectWithLazyRepository repository)
+ {
+ final ObjectWithLazy newLazy = new ObjectWithLazy<>();
+ final SimpleObject objectToStore = new SimpleObject(TestData.DUMMY_STRING);
+ newLazy.setLazy(SpringDataEclipseStoreLazy.build(objectToStore));
+ repository.save(newLazy);
+
+ restartDatastore(this.configuration);
+
+ final SimpleObject changedObjectToStore = new SimpleObject(TestData.DUMMY_STRING_ALTERNATIVE);
+ final ObjectWithLazy objectToChange = repository.findAll().get(0);
+ objectToChange.setLazy(SpringDataEclipseStoreLazy.build(changedObjectToStore));
+
+ Assertions.assertNotEquals(objectToChange.getLazy().get(), repository.findAll().get(0).getLazy().get());
+
+ repository.save(objectToChange);
+
+ final ObjectWithLazy workingCopy1 = repository.findAll().get(0);
+ final ObjectWithLazy workingCopy2 = repository.findAll().get(0);
+ Assertions.assertEquals(workingCopy1.getLazy().get(), workingCopy2.getLazy().get());
+ }
+
+ @Test
+ void lazyStoreComplexObject(@Autowired final ObjectWithLazyRepository repository)
+ {
+ final ObjectWithLazy newLazy = new ObjectWithLazy<>();
+ final ComplexLazyObject objectToStore = new ComplexLazyObject(
+ SpringDataEclipseStoreLazy.build(new SimpleObject(TestData.DUMMY_STRING)),
+ new ArrayList<>(Arrays.asList(
+ SpringDataEclipseStoreLazy.build(new ArrayList<>(Arrays.asList(TestData.DUMMY_STRING))),
+ SpringDataEclipseStoreLazy.build(new ArrayList<>(Arrays.asList(TestData.DUMMY_STRING_ALTERNATIVE)))
+ ))
+ );
+ newLazy.setLazy(SpringDataEclipseStoreLazy.build(objectToStore));
+ repository.save(newLazy);
+
+ TestUtil.doBeforeAndAfterRestartOfDatastore(
+ this.configuration,
+ () -> {
+ Assertions.assertEquals(1, repository.findAll().size());
+ final Lazy lazy = repository.findAll().get(0).getLazy();
+ Assertions.assertNotNull(lazy.get());
+ Assertions.assertEquals(objectToStore.getSimpleObject().get(), lazy.get().getSimpleObject().get());
+ Assertions.assertEquals(
+ objectToStore.getListOfLazyListOfString().size(),
+ lazy.get().getListOfLazyListOfString().size());
+ Assertions.assertEquals(
+ objectToStore.getListOfLazyListOfString().get(0).get(),
+ lazy.get().getListOfLazyListOfString().get(0).get());
+ Assertions.assertEquals(
+ objectToStore.getListOfLazyListOfString().get(1).get(),
+ lazy.get().getListOfLazyListOfString().get(1).get());
+ }
+ );
+ }
+
+ @Test
+ void lazyChangeComplexObject(@Autowired final ObjectWithLazyRepository repository)
+ {
+ final ObjectWithLazy newLazy = new ObjectWithLazy<>();
+ final ComplexLazyObject objectToStore = new ComplexLazyObject(
+ SpringDataEclipseStoreLazy.build(new SimpleObject(TestData.DUMMY_STRING)),
+ new ArrayList<>(Arrays.asList(
+ SpringDataEclipseStoreLazy.build(new ArrayList<>(Arrays.asList(TestData.DUMMY_STRING))),
+ SpringDataEclipseStoreLazy.build(new ArrayList<>(Arrays.asList(TestData.DUMMY_STRING_ALTERNATIVE)))
+ ))
+ );
+ newLazy.setLazy(SpringDataEclipseStoreLazy.build(objectToStore));
+ repository.save(newLazy);
+
+ restartDatastore(this.configuration);
+
+ final ObjectWithLazy loadedObjectToChange = repository.findAll().get(0);
+ loadedObjectToChange
+ .getLazy()
+ .get()
+ .getListOfLazyListOfString()
+ .add(SpringDataEclipseStoreLazy.build(List.of(TestData.DUMMY_STRING_ALTERNATIVE)));
+ repository.save(loadedObjectToChange);
+
+ TestUtil.doBeforeAndAfterRestartOfDatastore(
+ this.configuration,
+ () -> {
+ final ObjectWithLazy loadedObject = repository.findAll().get(0);
+ Assertions.assertNotSame(loadedObjectToChange, loadedObject);
+ Assertions.assertNotSame(
+ loadedObjectToChange.getLazy().get(),
+ loadedObject.getLazy().get()
+ );
+ Assertions.assertEquals(
+ loadedObjectToChange.getLazy().get().getListOfLazyListOfString().size(),
+ loadedObject.getLazy().get().getListOfLazyListOfString().size()
+ );
+ Assertions.assertEquals(
+ loadedObjectToChange.getLazy().get().getListOfLazyListOfString().get(0).get().size(),
+ loadedObject.getLazy().get().getListOfLazyListOfString().get(0).get().size()
+ );
+ Assertions.assertEquals(
+ loadedObjectToChange.getLazy().get().getListOfLazyListOfString().get(0).get().get(0),
+ loadedObject.getLazy().get().getListOfLazyListOfString().get(0).get().get(0)
+ );
+ }
+ );
+ }
+
+ @Test
+ void lazyReloadAndRestoreComplexObject(@Autowired final ObjectWithLazyRepository repository)
+ {
+ final ObjectWithLazy newLazy = new ObjectWithLazy<>();
+ final ComplexLazyObject objectToStore = new ComplexLazyObject(
+ SpringDataEclipseStoreLazy.build(new SimpleObject(TestData.DUMMY_STRING)),
+ new ArrayList<>(Arrays.asList(
+ SpringDataEclipseStoreLazy.build(new ArrayList<>(Arrays.asList(TestData.DUMMY_STRING))),
+ SpringDataEclipseStoreLazy.build(new ArrayList<>(Arrays.asList(TestData.DUMMY_STRING_ALTERNATIVE)))
+ ))
+ );
+ newLazy.setLazy(SpringDataEclipseStoreLazy.build(objectToStore));
+ repository.save(newLazy);
+
+ restartDatastore(this.configuration);
+
+ final ObjectWithLazy loadedObjectToChange = repository.findAll().get(0);
+ repository.save(loadedObjectToChange);
+
+ TestUtil.doBeforeAndAfterRestartOfDatastore(
+ this.configuration,
+ () -> {
+ final ObjectWithLazy loadedObject = repository.findAll().get(0);
+ Assertions.assertNotSame(loadedObjectToChange, loadedObject);
+ Assertions.assertNotSame(
+ loadedObjectToChange.getLazy().get(),
+ loadedObject.getLazy().get()
+ );
+ Assertions.assertEquals(
+ loadedObjectToChange.getLazy().get().getListOfLazyListOfString().size(),
+ loadedObject.getLazy().get().getListOfLazyListOfString().size()
+ );
+ Assertions.assertEquals(
+ loadedObjectToChange.getLazy().get().getListOfLazyListOfString().get(0).get().size(),
+ loadedObject.getLazy().get().getListOfLazyListOfString().get(0).get().size()
+ );
+ Assertions.assertEquals(
+ loadedObjectToChange.getLazy().get().getListOfLazyListOfString().get(0).get().get(0),
+ loadedObject.getLazy().get().getListOfLazyListOfString().get(0).get().get(0)
+ );
+ }
+ );
+ }
+
+ @Test
+ void lazyClearBeforeSave()
+ {
+ final ObjectWithLazy newLazy = new ObjectWithLazy<>();
+ final SimpleObject objectToStore = new SimpleObject(TestData.DUMMY_STRING);
+ newLazy.setLazy(SpringDataEclipseStoreLazy.build(objectToStore));
+ final Lazy lazy = newLazy.getLazy();
+ Assertions.assertThrows(IllegalStateException.class, () -> lazy.clear());
+ }
+
+ @Test
+ @Disabled("This should work at some point. At least a warning should be displayed.")
+ void lazyUseEclipseStoreLazy(@Autowired final ObjectWithLazyRepository repository)
+ {
+ final ObjectWithLazy newLazy = new ObjectWithLazy<>();
+ final SimpleObject objectToStore = new SimpleObject(TestData.DUMMY_STRING);
+ newLazy.setLazy(Lazy.Reference(objectToStore));
+ Assertions.assertThrows(Exception.class, () -> repository.save(newLazy));
+ }
+
+ @Test
+ void lazyClearAfterSave(@Autowired final ObjectWithLazyRepository repository)
+ {
+ final ObjectWithLazy newLazy = new ObjectWithLazy<>();
+ final SimpleObject objectToStore = new SimpleObject(TestData.DUMMY_STRING);
+ newLazy.setLazy(SpringDataEclipseStoreLazy.build(objectToStore));
+
+ Assertions.assertTrue(newLazy.getLazy().isLoaded());
+ Assertions.assertFalse(newLazy.getLazy().isStored());
+
+ repository.save(newLazy);
+
+ Assertions.assertTrue(newLazy.getLazy().isLoaded());
+ Assertions.assertTrue(newLazy.getLazy().isStored());
+
+ newLazy.getLazy().clear();
+
+ TestUtil.doBeforeAndAfterRestartOfDatastore(
+ this.configuration,
+ () -> {
+ Assertions.assertEquals(1, repository.findAll().size());
+ final Lazy lazy = repository.findAll().get(0).getLazy();
+ Assertions.assertFalse(lazy.isLoaded());
+ Assertions.assertEquals(objectToStore, lazy.get());
+ Assertions.assertTrue(lazy.isLoaded());
+ }
+ );
+ }
+
+ @Test
+ void lazyClearThroughLazyManagerAfterSave(@Autowired final ObjectWithLazyRepository repository)
+ {
+ final ObjectWithLazy newLazy = new ObjectWithLazy<>();
+ final SimpleObject objectToStore = new SimpleObject(TestData.DUMMY_STRING);
+ newLazy.setLazy(SpringDataEclipseStoreLazy.build(objectToStore));
+ repository.save(newLazy);
+ LazyReferenceManager.get().cleanUp();
+
+ TestUtil.doBeforeAndAfterRestartOfDatastore(
+ this.configuration,
+ () -> {
+ Assertions.assertEquals(1, repository.findAll().size());
+ final Lazy lazy = repository.findAll().get(0).getLazy();
+ Assertions.assertFalse(lazy.isLoaded());
+ Assertions.assertEquals(objectToStore, lazy.get());
+ Assertions.assertTrue(lazy.isLoaded());
+ }
+ );
+ }
+
+ @Test
+ void lazyClearAfterRestart(@Autowired final ObjectWithLazyRepository repository)
+ {
+ final ObjectWithLazy newLazy = new ObjectWithLazy<>();
+ final SimpleObject objectToStore = new SimpleObject(TestData.DUMMY_STRING);
+ newLazy.setLazy(SpringDataEclipseStoreLazy.build(objectToStore));
+ repository.save(newLazy);
+
+ restartDatastore(this.configuration);
+
+ Assertions.assertDoesNotThrow(() -> newLazy.getLazy().clear());
+ }
+
+ @Test
+ void lazyChangeAfterSave(@Autowired final ObjectWithLazyRepository repository)
+ {
+ final ObjectWithLazy newLazy = new ObjectWithLazy<>();
+ final SimpleObject objectToStore = new SimpleObject(TestData.DUMMY_STRING);
+ newLazy.setLazy(SpringDataEclipseStoreLazy.build(objectToStore));
+ repository.save(newLazy);
+
+ final SimpleObject objectToStore2 = new SimpleObject(TestData.DUMMY_STRING_ALTERNATIVE);
+ newLazy.setLazy(SpringDataEclipseStoreLazy.build(objectToStore2));
+ repository.save(newLazy);
+
+ TestUtil.doBeforeAndAfterRestartOfDatastore(
+ this.configuration,
+ () -> {
+ Assertions.assertEquals(1, repository.findAll().size());
+ final Lazy lazy = repository.findAll().get(0).getLazy();
+ Assertions.assertEquals(objectToStore2, lazy.get());
+ }
+ );
+ }
+
+ @Test
+ void lazyChangeBeforeSave(@Autowired final ObjectWithLazyRepository repository)
+ {
+ final ObjectWithLazy newLazy = new ObjectWithLazy<>();
+ final SimpleObject objectToStore = new SimpleObject(TestData.DUMMY_STRING);
+ newLazy.setLazy(SpringDataEclipseStoreLazy.build(objectToStore));
+
+ final SimpleObject objectToStore2 = new SimpleObject(TestData.DUMMY_STRING_ALTERNATIVE);
+ newLazy.setLazy(SpringDataEclipseStoreLazy.build(objectToStore2));
+ repository.save(newLazy);
+
+ TestUtil.doBeforeAndAfterRestartOfDatastore(
+ this.configuration,
+ () -> {
+ Assertions.assertEquals(1, repository.findAll().size());
+ final Lazy lazy = repository.findAll().get(0).getLazy();
+ Assertions.assertEquals(objectToStore2, lazy.get());
+ }
+ );
+ }
+
+ @Test
+ void lazyChangeAfterRestart(@Autowired final ObjectWithLazyRepository repository)
+ {
+ final ObjectWithLazy newLazy = new ObjectWithLazy<>();
+ final SimpleObject objectToStore = new SimpleObject(TestData.DUMMY_STRING);
+ newLazy.setLazy(SpringDataEclipseStoreLazy.build(objectToStore));
+ repository.save(newLazy);
+
+ restartDatastore(this.configuration);
+
+ Assertions.assertEquals(1, repository.findAll().size());
+ final ObjectWithLazy reloadedObjectWithLazy = repository.findAll().get(0);
+ Assertions.assertEquals(objectToStore, reloadedObjectWithLazy.getLazy().get());
+
+ final SimpleObject objectToStore2 = new SimpleObject(TestData.DUMMY_STRING_ALTERNATIVE);
+ reloadedObjectWithLazy.setLazy(SpringDataEclipseStoreLazy.build(objectToStore2));
+ repository.save(reloadedObjectWithLazy);
+
+ TestUtil.doBeforeAndAfterRestartOfDatastore(
+ this.configuration,
+ () -> {
+ Assertions.assertEquals(1, repository.findAll().size());
+ final Lazy lazy = repository.findAll().get(0).getLazy();
+ Assertions.assertEquals(objectToStore2, lazy.get());
+ }
+ );
+ }
+}
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/LazyTestConfiguration.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/LazyTestConfiguration.java
new file mode 100644
index 00000000..75dcafa4
--- /dev/null
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/LazyTestConfiguration.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright © 2024 XDEV Software (https://xdev.software)
+ *
+ * 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
+ *
+ * http://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.integration.isolated.tests.lazy;
+
+import org.springframework.context.annotation.Configuration;
+
+import software.xdev.spring.data.eclipse.store.integration.TestConfiguration;
+import software.xdev.spring.data.eclipse.store.repository.config.EnableEclipseStoreRepositories;
+
+
+@Configuration
+@EnableEclipseStoreRepositories(clientConfigurationClass = LazyTestConfiguration.class)
+public class LazyTestConfiguration extends TestConfiguration
+{
+}
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/ObjectWithLazy.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/ObjectWithLazy.java
new file mode 100644
index 00000000..f670d298
--- /dev/null
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/ObjectWithLazy.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright © 2024 XDEV Software (https://xdev.software)
+ *
+ * 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
+ *
+ * http://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.integration.isolated.tests.lazy;
+
+import org.eclipse.serializer.reference.Lazy;
+
+
+public class ObjectWithLazy
+{
+ private Lazy lazy;
+
+ public Lazy getLazy()
+ {
+ return this.lazy;
+ }
+
+ public void setLazy(final Lazy lazy)
+ {
+ this.lazy = lazy;
+ }
+}
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/ObjectWithLazyHashMap.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/ObjectWithLazyHashMap.java
new file mode 100644
index 00000000..10b2f430
--- /dev/null
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/ObjectWithLazyHashMap.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright © 2024 XDEV Software (https://xdev.software)
+ *
+ * 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
+ *
+ * http://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.integration.isolated.tests.lazy;
+
+import org.eclipse.serializer.collections.lazy.LazyHashMap;
+
+
+public class ObjectWithLazyHashMap
+{
+ private LazyHashMap lazyHashMap;
+
+ public LazyHashMap getLazyHashMap()
+ {
+ return this.lazyHashMap;
+ }
+
+ public void setLazyHashMap(final LazyHashMap lazyHashMap)
+ {
+ this.lazyHashMap = lazyHashMap;
+ }
+}
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/ObjectWithLazyHashMapRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/ObjectWithLazyHashMapRepository.java
new file mode 100644
index 00000000..3a4f8857
--- /dev/null
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/ObjectWithLazyHashMapRepository.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright © 2024 XDEV Software (https://xdev.software)
+ *
+ * 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
+ *
+ * http://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.integration.isolated.tests.lazy;
+
+import org.springframework.data.repository.ListCrudRepository;
+
+
+public interface ObjectWithLazyHashMapRepository extends ListCrudRepository
+{
+}
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/ObjectWithLazyHashSet.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/ObjectWithLazyHashSet.java
new file mode 100644
index 00000000..2f8b0cd4
--- /dev/null
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/ObjectWithLazyHashSet.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright © 2024 XDEV Software (https://xdev.software)
+ *
+ * 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
+ *
+ * http://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.integration.isolated.tests.lazy;
+
+import org.eclipse.serializer.collections.lazy.LazyHashSet;
+
+
+public class ObjectWithLazyHashSet
+{
+ private LazyHashSet lazyHashSet;
+
+ public LazyHashSet getLazyHashSet()
+ {
+ return this.lazyHashSet;
+ }
+
+ public void setLazyHashSet(final LazyHashSet lazyHashSet)
+ {
+ this.lazyHashSet = lazyHashSet;
+ }
+}
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/ObjectWithLazyHashSetRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/ObjectWithLazyHashSetRepository.java
new file mode 100644
index 00000000..070ff4b8
--- /dev/null
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/ObjectWithLazyHashSetRepository.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright © 2024 XDEV Software (https://xdev.software)
+ *
+ * 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
+ *
+ * http://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.integration.isolated.tests.lazy;
+
+import org.springframework.data.repository.ListCrudRepository;
+
+
+public interface ObjectWithLazyHashSetRepository extends ListCrudRepository
+{
+}
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/ObjectWithLazyList.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/ObjectWithLazyList.java
new file mode 100644
index 00000000..e15783c0
--- /dev/null
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/ObjectWithLazyList.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright © 2024 XDEV Software (https://xdev.software)
+ *
+ * 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
+ *
+ * http://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.integration.isolated.tests.lazy;
+
+import org.eclipse.serializer.collections.lazy.LazyList;
+
+
+public class ObjectWithLazyList
+{
+ private LazyList lazyList;
+
+ public LazyList getLazyList()
+ {
+ return this.lazyList;
+ }
+
+ public void setLazyList(final LazyList lazyList)
+ {
+ this.lazyList = lazyList;
+ }
+}
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/ObjectWithLazyListRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/ObjectWithLazyListRepository.java
new file mode 100644
index 00000000..773e1d0d
--- /dev/null
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/ObjectWithLazyListRepository.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright © 2024 XDEV Software (https://xdev.software)
+ *
+ * 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
+ *
+ * http://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.integration.isolated.tests.lazy;
+
+import org.springframework.data.repository.ListCrudRepository;
+
+
+public interface ObjectWithLazyListRepository extends ListCrudRepository
+{
+}
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/ObjectWithLazyRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/ObjectWithLazyRepository.java
new file mode 100644
index 00000000..a0e4164f
--- /dev/null
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/ObjectWithLazyRepository.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright © 2024 XDEV Software (https://xdev.software)
+ *
+ * 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
+ *
+ * http://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.integration.isolated.tests.lazy;
+
+import org.springframework.data.repository.ListCrudRepository;
+
+
+public interface ObjectWithLazyRepository extends ListCrudRepository, Integer>
+{
+}
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/ObjectWithLazySimpleObject.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/ObjectWithLazySimpleObject.java
new file mode 100644
index 00000000..75dbfb07
--- /dev/null
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/ObjectWithLazySimpleObject.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright © 2024 XDEV Software (https://xdev.software)
+ *
+ * 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
+ *
+ * http://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.integration.isolated.tests.lazy;
+
+public class ObjectWithLazySimpleObject
+{
+ private SimpleObject lazySimpleObject;
+
+ public SimpleObject getLazySimpleObject()
+ {
+ return this.lazySimpleObject;
+ }
+
+ public void setLazySimpleObject(final SimpleObject lazySimpleObject)
+ {
+ this.lazySimpleObject = lazySimpleObject;
+ }
+}
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/ObjectWithLazySimpleObjectRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/ObjectWithLazySimpleObjectRepository.java
new file mode 100644
index 00000000..4bd550a6
--- /dev/null
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/ObjectWithLazySimpleObjectRepository.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright © 2024 XDEV Software (https://xdev.software)
+ *
+ * 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
+ *
+ * http://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.integration.isolated.tests.lazy;
+
+import org.springframework.data.repository.ListCrudRepository;
+
+
+public interface ObjectWithLazySimpleObjectRepository extends ListCrudRepository
+{
+}
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/SimpleObject.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/SimpleObject.java
new file mode 100644
index 00000000..f09879e4
--- /dev/null
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/SimpleObject.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright © 2024 XDEV Software (https://xdev.software)
+ *
+ * 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
+ *
+ * http://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.integration.isolated.tests.lazy;
+
+public record SimpleObject(String value)
+{
+}
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/BigDecimalDaoObject.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/BigDecimalDaoObject.java
index 52c42c58..bbb331d6 100644
--- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/BigDecimalDaoObject.java
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/BigDecimalDaoObject.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/BigDecimalRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/BigDecimalRepository.java
index f56eb4a8..44451dde 100644
--- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/BigDecimalRepository.java
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/BigDecimalRepository.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/BigIntegerDaoObject.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/BigIntegerDaoObject.java
index 90dc44f1..5dba8163 100644
--- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/BigIntegerDaoObject.java
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/BigIntegerDaoObject.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/BigIntegerRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/BigIntegerRepository.java
index 74a8d364..7dcc0f5e 100644
--- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/BigIntegerRepository.java
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/BigIntegerRepository.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/CalendarDaoObject.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/CalendarDaoObject.java
index 3b835475..df30ccbc 100644
--- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/CalendarDaoObject.java
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/CalendarDaoObject.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/CalendarRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/CalendarRepository.java
index 187d33fb..85451deb 100644
--- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/CalendarRepository.java
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/CalendarRepository.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/ComplexObject.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/ComplexObject.java
index 5561bb6c..6c5b61ab 100644
--- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/ComplexObject.java
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/ComplexObject.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/DateDaoObject.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/DateDaoObject.java
index f93dfa12..6a3b066f 100644
--- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/DateDaoObject.java
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/DateDaoObject.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/DateRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/DateRepository.java
index f967c16f..b25a000d 100644
--- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/DateRepository.java
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/DateRepository.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/EnumMapDaoObject.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/EnumMapDaoObject.java
index cd81c07c..dfd07ec3 100644
--- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/EnumMapDaoObject.java
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/EnumMapDaoObject.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/EnumMapRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/EnumMapRepository.java
index 4f49be48..77f5ce6e 100644
--- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/EnumMapRepository.java
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/EnumMapRepository.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/EnumSetDaoObject.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/EnumSetDaoObject.java
index 31acf389..01738257 100644
--- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/EnumSetDaoObject.java
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/EnumSetDaoObject.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/EnumSetRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/EnumSetRepository.java
index f2f186b8..aea2509a 100644
--- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/EnumSetRepository.java
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/EnumSetRepository.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/LazyDaoObject.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/LazyDaoObject.java
index 41221a67..a58bf983 100644
--- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/LazyDaoObject.java
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/LazyDaoObject.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,6 +15,8 @@
*/
package software.xdev.spring.data.eclipse.store.integration.isolated.tests.special.types;
+import java.util.Objects;
+
import org.eclipse.serializer.reference.Lazy;
@@ -24,4 +26,29 @@ public LazyDaoObject(final Integer id, final Lazy value)
{
super(id, value);
}
+
+ @Override
+ public int hashCode()
+ {
+ return super.hashCode();
+ }
+
+ @Override
+ public boolean equals(final Object o)
+ {
+ if(this == o)
+ {
+ return true;
+ }
+ if(o == null || this.getClass() != o.getClass())
+ {
+ return false;
+ }
+ final ComplexObject> that = (ComplexObject>)o;
+ return Objects.equals(this.getId(), that.getId())
+ && (this.getValue() == null && that.getValue() == null)
+ || Objects.equals(
+ this.getValue().get(),
+ that.getValue().get());
+ }
}
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/LazyRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/LazyRepository.java
index a3cd5e37..812806ee 100644
--- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/LazyRepository.java
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/LazyRepository.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/ListDaoObject.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/ListDaoObject.java
index f4cb80e7..8d6b1154 100644
--- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/ListDaoObject.java
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/ListDaoObject.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/ListRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/ListRepository.java
index b0351524..3aad2865 100644
--- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/ListRepository.java
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/ListRepository.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/LocalDateDaoObject.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/LocalDateDaoObject.java
index bf6cf781..c232caa1 100644
--- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/LocalDateDaoObject.java
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/LocalDateDaoObject.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/LocalDateRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/LocalDateRepository.java
index 0aa50229..a44c110d 100644
--- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/LocalDateRepository.java
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/LocalDateRepository.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/LocalDateTimeDaoObject.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/LocalDateTimeDaoObject.java
index 169ea937..6a4e5ac9 100644
--- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/LocalDateTimeDaoObject.java
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/LocalDateTimeDaoObject.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/LocalDateTimeRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/LocalDateTimeRepository.java
index 737c6ebf..c5d83582 100644
--- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/LocalDateTimeRepository.java
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/LocalDateTimeRepository.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/LocalTimeDaoObject.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/LocalTimeDaoObject.java
index 953aeab5..6ae4c6b1 100644
--- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/LocalTimeDaoObject.java
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/LocalTimeDaoObject.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/LocalTimeRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/LocalTimeRepository.java
index db1cac67..046295b0 100644
--- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/LocalTimeRepository.java
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/LocalTimeRepository.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/MapDaoObject.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/MapDaoObject.java
index 372ec6b3..fc466f74 100644
--- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/MapDaoObject.java
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/MapDaoObject.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/MapRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/MapRepository.java
index ebbb1d18..4e9e790d 100644
--- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/MapRepository.java
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/MapRepository.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/OptionalDaoObject.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/OptionalDaoObject.java
index 228abedc..6a50a276 100644
--- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/OptionalDaoObject.java
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/OptionalDaoObject.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/OptionalRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/OptionalRepository.java
index 7868afc6..be0456d0 100644
--- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/OptionalRepository.java
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/OptionalRepository.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/SetDaoObject.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/SetDaoObject.java
index be214b09..07dcf5dc 100644
--- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/SetDaoObject.java
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/SetDaoObject.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/SetRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/SetRepository.java
index e3ed468b..c75f089f 100644
--- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/SetRepository.java
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/SetRepository.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/SpecialTypesTestConfiguration.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/SpecialTypesTestConfiguration.java
new file mode 100644
index 00000000..54a8bc9a
--- /dev/null
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/SpecialTypesTestConfiguration.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright © 2024 XDEV Software (https://xdev.software)
+ *
+ * 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
+ *
+ * http://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.integration.isolated.tests.special.types;
+
+import org.springframework.context.annotation.Configuration;
+
+import software.xdev.spring.data.eclipse.store.integration.TestConfiguration;
+import software.xdev.spring.data.eclipse.store.repository.config.EnableEclipseStoreRepositories;
+
+
+@Configuration
+@EnableEclipseStoreRepositories(clientConfigurationClass = SpecialTypesTestConfiguration.class)
+public class SpecialTypesTestConfiguration extends TestConfiguration
+{
+}
diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/TypesData.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/TypesData.java
index 4429ddb6..0062d6de 100644
--- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/TypesData.java
+++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/TypesData.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
+ * Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -44,14 +44,21 @@
import java.util.function.Function;
import java.util.stream.Stream;
-import org.eclipse.serializer.reference.Lazy;
+import org.eclipse.serializer.collections.lazy.LazyArrayList;
+import org.eclipse.serializer.collections.lazy.LazyHashMap;
+import org.eclipse.serializer.collections.lazy.LazyHashSet;
import org.junit.jupiter.params.provider.Arguments;
import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreRepository;
+import software.xdev.spring.data.eclipse.store.repository.lazy.SpringDataEclipseStoreLazy;
final class TypesData
{
+ private TypesData()
+ {
+ }
+
public record ListOfTestArguments(List> testArguments)
{
public Stream toArguments()
@@ -378,6 +385,11 @@ public static Stream generateData()
OptionalRepository.class,
id -> new OptionalDaoObject(id, null),
set -> set.setValue(Optional.of("1"))
+ ),
+ new TestArguments<>(
+ LazyRepository.class,
+ id -> new LazyDaoObject(id, SpringDataEclipseStoreLazy.build("1")),
+ object -> object.setValue(SpringDataEclipseStoreLazy.build("2"))
)
)
).toArguments();
@@ -392,16 +404,6 @@ public static Stream generateNotWorkingData()
{
return new ListOfTestArguments(
List.of(
- new TestArguments<>(
- LazyRepository.class,
- id -> new LazyDaoObject(id, Lazy.Reference("1")),
- object -> object.setValue(Lazy.Reference("2"))
- ),
- new TestArguments<>(
- LazyRepository.class,
- id -> new LazyDaoObject(id, Lazy.Reference("1")),
- object -> object.getValue().clear()
- ),
new TestArguments<>(
EnumMapRepository.class,
id -> new EnumMapDaoObject(id, new EnumMap<>(EnumMapDaoObject.Album.class)),
@@ -436,6 +438,82 @@ public static Stream generateNotWorkingData()
CalendarRepository.class,
id -> new CalendarDaoObject(id, Calendar.getInstance()),
object -> object.getValue().add(Calendar.DAY_OF_MONTH, 1)
+ ),
+ new TestArguments<>(
+ MapRepository.class,
+ id -> {
+ final LazyHashMap lazyHashMap = new LazyHashMap<>();
+ lazyHashMap.put("1", "1");
+ return new MapDaoObject(id, lazyHashMap);
+ },
+ set -> set.getValue().put("2", "2")
+ ),
+ new TestArguments<>(
+ MapRepository.class,
+ id -> {
+ final LazyHashMap lazyHashMap = new LazyHashMap<>();
+ lazyHashMap.put("1", "1");
+ lazyHashMap.put("2", "2");
+ return new MapDaoObject(id, lazyHashMap);
+ },
+ set -> set.getValue().put("3", "3")
+ ),
+ new TestArguments<>(
+ SetRepository.class,
+ id -> new SetDaoObject(id, new LazyHashSet<>()),
+ set -> set.getValue().add("1")
+ ),
+ new TestArguments<>(
+ SetRepository.class,
+ id ->
+ {
+ final LazyHashSet set = new LazyHashSet<>();
+ set.add("1");
+ return new SetDaoObject(id, set);
+ },
+ set -> set.getValue().add("2")
+ ),
+ new TestArguments<>(
+ SetRepository.class,
+ id ->
+ {
+ final LazyHashSet set = new LazyHashSet<>();
+ set.add("1");
+ set.add("2");
+ return new SetDaoObject(id, set);
+ },
+ set -> set.getValue().add("3")
+ ),
+ new TestArguments<>(
+ ListRepository.class,
+ id -> new ListDaoObject(id, new LazyArrayList<>()),
+ object -> object.getValue().add("1")
+ ),
+ new TestArguments<>(
+ ListRepository.class,
+ id ->
+ {
+ final LazyArrayList list = new LazyArrayList<>();
+ list.add("1");
+ return new ListDaoObject(id, list);
+ },
+ object -> object.getValue().add("2")
+ ),
+ new TestArguments<>(
+ ListRepository.class,
+ id ->
+ {
+ final LazyArrayList