Skip to content

Commit 8697304

Browse files
Lazy References in Repositories are now real ES Lazies
1 parent c597730 commit 8697304

6 files changed

Lines changed: 66 additions & 4 deletions

File tree

spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/VersionedRoot.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ public VersionedRoot()
4444
public VersionedRoot(final Root rootDataV1)
4545
{
4646
this.rootDataV1 = rootDataV1;
47-
this.rootDataV2 = new RootDataV2();
4847
this.rootDataV2_4 = new RootDataV2_4();
4948
if(rootDataV1 != null)
5049
{

spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/root/v2_4/LazyEntityData.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import org.eclipse.serializer.reference.Referencing;
2525

2626
import software.xdev.spring.data.eclipse.store.core.IdentitySet;
27-
import software.xdev.spring.data.eclipse.store.repository.lazy.SpringDataEclipseStoreLazy;
2827
import software.xdev.spring.data.eclipse.store.repository.support.id.IdGetter;
2928

3029

@@ -131,7 +130,9 @@ public Collection<Object> ensureEntityAndReturnObjectsToStore(final T entityToSt
131130
Collection<Object> listToSave = List.of();
132131
if(this.idGetter == null && !this.containsEntity(entityToStore))
133132
{
134-
this.entities.add(SpringDataEclipseStoreLazy.build(entityToStore));
133+
// Does not create a SpringDataEclipseStore.Lazy Instance, but a EclipseStore.Lazy because this is
134+
// outside the scope of the SpringDataEclipseStore.Lazy. No conversion is taking place.
135+
this.entities.add(Lazy.Reference(entityToStore));
135136
listToSave = this.getObjectsToStore();
136137
}
137138
if(this.idGetter != null)
@@ -140,7 +141,9 @@ public Collection<Object> ensureEntityAndReturnObjectsToStore(final T entityToSt
140141
if(existingEntity == null || existingEntity.get() != entityToStore)
141142
{
142143
this.entities.remove(existingEntity);
143-
final SpringDataEclipseStoreLazy<T> newLazyInstance = SpringDataEclipseStoreLazy.build(entityToStore);
144+
// Does not create a SpringDataEclipseStore.Lazy Instance, but a EclipseStore.Lazy because this is
145+
// outside the scope of the SpringDataEclipseStore.Lazy. No conversion is taking place.
146+
final Lazy<T> newLazyInstance = Lazy.Reference(entityToStore);
144147
this.entities.add(newLazyInstance);
145148
this.entitiesById.put(this.idGetter.getId(entityToStore), newLazyInstance);
146149
listToSave = this.getObjectsToStore();

spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/lazy/LazySimpleMultipleTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/*
2+
* Copyright © 2024 XDEV Software (https://xdev.software)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
package software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.lazy;
217

318
import org.springframework.beans.factory.annotation.Autowired;

spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/lazy/LazySimpleSingleTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/*
2+
* Copyright © 2024 XDEV Software (https://xdev.software)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
package software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.lazy;
217

318
import org.springframework.beans.factory.annotation.Autowired;

spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/nonlazy/NonLazySimpleMultipleTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/*
2+
* Copyright © 2024 XDEV Software (https://xdev.software)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
package software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.nonlazy;
217

318
import org.springframework.beans.factory.annotation.Autowired;

spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/simple/nonlazy/NonLazySimpleSingleTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/*
2+
* Copyright © 2024 XDEV Software (https://xdev.software)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
package software.xdev.spring.data.eclipse.store.integration.isolated.tests.simple.nonlazy;
217

318
import org.springframework.beans.factory.annotation.Autowired;

0 commit comments

Comments
 (0)