Skip to content

Commit 00d4907

Browse files
LazyRepositories: Added basic LazySimpleEclipseStoreRepository
1 parent 69f16ef commit 00d4907

16 files changed

Lines changed: 528 additions & 17 deletions

spring-data-eclipse-store/pom.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,8 @@
314314
<artifactId>maven-compiler-plugin</artifactId>
315315
<version>3.13.0</version>
316316
<configuration>
317+
<source>${javaVersion}</source>
318+
<target>${javaVersion}</target>
317319
<release>${maven.compiler.release}</release>
318320
<compilerArgs>
319321
<arg>-proc:none</arg>

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import software.xdev.spring.data.eclipse.store.exceptions.InvalidRootException;
3939
import software.xdev.spring.data.eclipse.store.repository.config.EclipseStoreClientConfiguration;
4040
import software.xdev.spring.data.eclipse.store.repository.config.EclipseStoreStorageFoundationProvider;
41+
import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreRepository;
4142
import software.xdev.spring.data.eclipse.store.repository.root.EntityData;
4243
import software.xdev.spring.data.eclipse.store.repository.root.VersionedRoot;
4344
import software.xdev.spring.data.eclipse.store.repository.support.SimpleEclipseStoreRepository;
@@ -58,7 +59,7 @@ public class EclipseStoreStorage
5859
implements EntityListProvider, IdManagerProvider, VersionManagerProvider, PersistableChecker, ObjectSwizzling
5960
{
6061
private static final Logger LOG = LoggerFactory.getLogger(EclipseStoreStorage.class);
61-
private final Map<Class<?>, SimpleEclipseStoreRepository<?, ?>> entityClassToRepository = new HashMap<>();
62+
private final Map<Class<?>, EclipseStoreRepository<?, ?>> entityClassToRepository = new HashMap<>();
6263
/**
6364
* "Why are the IdManagers seperated from the repositories?" - Because there might be entities for which there are
6465
* no repositories, but they still have IDs.
@@ -155,9 +156,9 @@ else if(!(embeddedStorageManager.root() instanceof VersionedRoot))
155156
return embeddedStorageFoundation;
156157
}
157158

158-
public <T> SimpleEclipseStoreRepository<T, ?> getRepository(final Class<T> entityClass)
159+
public <T> EclipseStoreRepository<?, ?> getRepository(final Class<T> entityClass)
159160
{
160-
return (SimpleEclipseStoreRepository<T, ?>)this.entityClassToRepository.get(entityClass);
161+
return this.entityClassToRepository.get(entityClass);
161162
}
162163

163164
private void initRoot()
@@ -217,7 +218,7 @@ private <T, ID> void setIdManagerForEntityData(final Class<T> entityClass, final
217218

218219
public synchronized <T> void registerEntity(
219220
final Class<T> classToRegister,
220-
final SimpleEclipseStoreRepository<T, ?> repository)
221+
final EclipseStoreRepository<?, ?> repository)
221222
{
222223
if(this.entityClassToRepository.containsKey(classToRegister))
223224
{

spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/config/EclipseStoreRepositoryConfigurationExtension.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@
3737
import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreListPagingAndSortingRepositoryRepository;
3838
import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStorePagingAndSortingRepositoryRepository;
3939
import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreRepository;
40+
import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStoreCrudRepository;
41+
import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStoreCustomRepository;
42+
import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStoreListCrudRepository;
43+
import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStoreListPagingAndSortingRepositoryRepository;
44+
import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStorePagingAndSortingRepositoryRepository;
45+
import software.xdev.spring.data.eclipse.store.repository.interfaces.lazy.LazyEclipseStoreRepository;
4046
import software.xdev.spring.data.eclipse.store.repository.support.EclipseStoreRepositoryFactoryBean;
4147

4248

@@ -121,7 +127,13 @@ protected Collection<Class<?>> getIdentifyingTypes()
121127
EclipseStorePagingAndSortingRepositoryRepository.class,
122128
EclipseStoreListPagingAndSortingRepositoryRepository.class,
123129
EclipseStoreCrudRepository.class,
124-
EclipseStoreListCrudRepository.class
130+
EclipseStoreListCrudRepository.class,
131+
LazyEclipseStoreRepository.class,
132+
LazyEclipseStoreCustomRepository.class,
133+
LazyEclipseStorePagingAndSortingRepositoryRepository.class,
134+
LazyEclipseStoreListPagingAndSortingRepositoryRepository.class,
135+
LazyEclipseStoreCrudRepository.class,
136+
LazyEclipseStoreListCrudRepository.class
125137
);
126138
}
127139

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
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+
*/
16+
package software.xdev.spring.data.eclipse.store.repository.interfaces.lazy;
17+
18+
import org.eclipse.serializer.reference.Lazy;
19+
import org.springframework.data.repository.CrudRepository;
20+
import org.springframework.data.repository.NoRepositoryBean;
21+
22+
23+
@SuppressWarnings("java:S119")
24+
@NoRepositoryBean
25+
public interface LazyEclipseStoreCrudRepository<T, ID> extends CrudRepository<Lazy<T>, ID>
26+
{
27+
/**
28+
* @inheritDoc <b>Caution with referenced objects!</b><br/> If you are deleting an object that is referenced by
29+
* another object, the behavior of this function may differ from what you are used to!
30+
* <p>
31+
* JPA would throw a {@code JdbcSQLIntegrityConstraintViolationException} but it would be very expensive to search
32+
* the referencedObject in the complete object tree and throw the exception.
33+
* <p>
34+
* That is why this library simply removes the element from the repository, but if it is still referenced by
35+
* another
36+
* object, this <b>reference is still working and pointing to the object</b>. That means that in fact this the
37+
* object to remove could very well stay in the storage if it is referenced.
38+
* </p>
39+
*/
40+
@Override
41+
void deleteById(ID id);
42+
43+
/**
44+
* @inheritDoc <b>Caution with referenced objects!</b><br/> If you are deleting an object that is referenced by
45+
* another object, the behavior of this function may differ from what you are used to!
46+
* <p>
47+
* For more information see {@link #deleteById(Object)}
48+
* </p>
49+
*/
50+
void deleteEntity(T entity);
51+
52+
/**
53+
* @inheritDoc <b>Caution with referenced objects!</b><br/> If you are deleting an object that is referenced by
54+
* another object, the behavior of this function may differ from what you are used to!
55+
* <p>
56+
* For more information see {@link #deleteById(Object)}
57+
* </p>
58+
*/
59+
@Override
60+
void delete(Lazy<T> entity);
61+
62+
/**
63+
* @inheritDoc <b>Caution with referenced objects!</b><br/> If you are deleting an object that is referenced by
64+
* another object, the behavior of this function may differ from what you are used to!
65+
* <p>
66+
* For more information see {@link #deleteById(Object)}
67+
* </p>
68+
*/
69+
@Override
70+
void deleteAllById(Iterable<? extends ID> ids);
71+
72+
/**
73+
* @inheritDoc <b>Caution with referenced objects!</b><br/> If you are deleting an object that is referenced by
74+
* another object, the behavior of this function may differ from what you are used to!
75+
* <p>
76+
* For more information see {@link #deleteById(Object)}
77+
* </p>
78+
*/
79+
@Override
80+
void deleteAll(Iterable<? extends Lazy<T>> entities);
81+
82+
/**
83+
* @inheritDoc <b>Caution with referenced objects!</b><br/> If you are deleting an object that is referenced by
84+
* another object, the behavior of this function may differ from what you are used to!
85+
* <p>
86+
* For more information see {@link #deleteById(Object)}
87+
* </p>
88+
*/
89+
void deleteAllEntities(Iterable<? extends T> entities);
90+
91+
/**
92+
* @inheritDoc <b>Caution with referenced objects!</b><br/> If you are deleting an object that is referenced by
93+
* another object, the behavior of this function may differ from what you are used to!
94+
* <p>
95+
* For more information see {@link #deleteById(Object)}
96+
* </p>
97+
*/
98+
@Override
99+
void deleteAll();
100+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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+
*/
16+
package software.xdev.spring.data.eclipse.store.repository.interfaces.lazy;
17+
18+
import org.eclipse.serializer.reference.Lazy;
19+
import org.springframework.data.repository.NoRepositoryBean;
20+
import org.springframework.data.repository.Repository;
21+
22+
23+
@SuppressWarnings("java:S119")
24+
@NoRepositoryBean
25+
public interface LazyEclipseStoreCustomRepository<T, ID> extends Repository<Lazy<T>, ID>
26+
{
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
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+
*/
16+
package software.xdev.spring.data.eclipse.store.repository.interfaces.lazy;
17+
18+
import java.util.List;
19+
20+
import org.eclipse.serializer.reference.Lazy;
21+
import org.springframework.data.repository.ListCrudRepository;
22+
import org.springframework.data.repository.NoRepositoryBean;
23+
24+
25+
@SuppressWarnings("java:S119")
26+
@NoRepositoryBean
27+
public interface LazyEclipseStoreListCrudRepository<T, ID> extends ListCrudRepository<Lazy<T>, ID>
28+
{
29+
/**
30+
* @inheritDoc <b>Caution with referenced objects!</b><br/> If you are deleting an object that is referenced by
31+
* another object, the behavior of this function may differ from what you are used to!
32+
* <p>
33+
* For more information see {@link LazyEclipseStoreCrudRepository#deleteById(Object)}
34+
* </p>
35+
*/
36+
@Override
37+
void deleteById(ID id);
38+
39+
/**
40+
* @inheritDoc <b>Caution with referenced objects!</b><br/> If you are deleting an object that is referenced by
41+
* another object, the behavior of this function may differ from what you are used to!
42+
* <p>
43+
* For more information see {@link LazyEclipseStoreCrudRepository#deleteById(Object)}
44+
* </p>
45+
*/
46+
@Override
47+
void delete(Lazy<T> entity);
48+
49+
/**
50+
* @inheritDoc <b>Caution with referenced objects!</b><br/> If you are deleting an object that is referenced by
51+
* another object, the behavior of this function may differ from what you are used to!
52+
* <p>
53+
* For more information see {@link LazyEclipseStoreCrudRepository#deleteById(Object)}
54+
* </p>
55+
*/
56+
void deleteEntity(T entity);
57+
58+
/**
59+
* @inheritDoc <b>Caution with referenced objects!</b><br/> If you are deleting an object that is referenced by
60+
* another object, the behavior of this function may differ from what you are used to!
61+
* <p>
62+
* For more information see {@link LazyEclipseStoreCrudRepository#deleteById(Object)}
63+
* </p>
64+
*/
65+
@Override
66+
void deleteAllById(Iterable<? extends ID> ids);
67+
68+
/**
69+
* @inheritDoc <b>Caution with referenced objects!</b><br/> If you are deleting an object that is referenced by
70+
* another object, the behavior of this function may differ from what you are used to!
71+
* <p>
72+
* For more information see {@link LazyEclipseStoreCrudRepository#deleteById(Object)}
73+
* </p>
74+
*/
75+
@Override
76+
void deleteAll(Iterable<? extends Lazy<T>> entities);
77+
78+
/**
79+
* @inheritDoc <b>Caution with referenced objects!</b><br/> If you are deleting an object that is referenced by
80+
* another object, the behavior of this function may differ from what you are used to!
81+
* <p>
82+
* For more information see {@link LazyEclipseStoreCrudRepository#deleteById(Object)}
83+
* </p>
84+
*/
85+
void deleteAllEntities(Iterable<? extends T> entities);
86+
87+
/**
88+
* @inheritDoc <b>Caution with referenced objects!</b><br/> If you are deleting an object that is referenced by
89+
* another object, the behavior of this function may differ from what you are used to!
90+
* <p>
91+
* For more information see {@link LazyEclipseStoreCrudRepository#deleteById(Object)}
92+
* </p>
93+
*/
94+
@Override
95+
void deleteAll();
96+
97+
<S extends T> List<S> saveAllEntities(Iterable<S> entities);
98+
99+
<S extends T> S saveEntity(S entity);
100+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
*/
16+
package software.xdev.spring.data.eclipse.store.repository.interfaces.lazy;
17+
18+
import org.eclipse.serializer.reference.Lazy;
19+
import org.springframework.data.repository.ListPagingAndSortingRepository;
20+
import org.springframework.data.repository.NoRepositoryBean;
21+
22+
23+
@SuppressWarnings("java:S119")
24+
@NoRepositoryBean
25+
public interface LazyEclipseStoreListPagingAndSortingRepositoryRepository<T, ID>
26+
extends ListPagingAndSortingRepository<Lazy<T>, ID>
27+
{
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
*/
16+
package software.xdev.spring.data.eclipse.store.repository.interfaces.lazy;
17+
18+
import org.eclipse.serializer.reference.Lazy;
19+
import org.springframework.data.repository.NoRepositoryBean;
20+
import org.springframework.data.repository.PagingAndSortingRepository;
21+
22+
23+
@SuppressWarnings("java:S119")
24+
@NoRepositoryBean
25+
public interface LazyEclipseStorePagingAndSortingRepositoryRepository<T, ID>
26+
extends PagingAndSortingRepository<Lazy<T>, ID>
27+
{
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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+
*/
16+
package software.xdev.spring.data.eclipse.store.repository.interfaces.lazy;
17+
18+
import org.eclipse.serializer.reference.Lazy;
19+
import org.springframework.data.repository.NoRepositoryBean;
20+
import org.springframework.data.repository.query.QueryByExampleExecutor;
21+
22+
23+
@SuppressWarnings("java:S119")
24+
@NoRepositoryBean
25+
public interface LazyEclipseStoreQueryByExampleExecutor<T> extends QueryByExampleExecutor<Lazy<T>>
26+
{
27+
}

0 commit comments

Comments
 (0)