Skip to content

Commit 11cecf9

Browse files
added deletion javadoc
1 parent 87e6a30 commit 11cecf9

File tree

3 files changed

+116
-7
lines changed

3 files changed

+116
-7
lines changed

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

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,59 @@
2323
@NoRepositoryBean
2424
public interface EclipseStoreCrudRepository<T, ID> extends CrudRepository<T, ID>
2525
{
26+
/**
27+
* @inheritDoc <b>Caution with referenced objects!</b><br/> If you are deleting an object that is referenced by
28+
* another object, the behavior of this function may differ from what you are used to!
29+
* <p>
30+
* JPA would throw a {@code JdbcSQLIntegrityConstraintViolationException} but it would be very expensive to search
31+
* the referencedObject in the complete object tree and throw the exception.
32+
* <p>
33+
* That is why this library simply removes the element from the repository, but if it is still referenced by
34+
* another
35+
* object, this <b>reference is still working and pointing to the object</b>. That means that in fact this the
36+
* object to remove could very well stay in the storage if it is referenced.
37+
* </p>
38+
*/
39+
@Override
40+
void deleteById(ID id);
41+
42+
/**
43+
* @inheritDoc <b>Caution with referenced objects!</b><br/> If you are deleting an object that is referenced by
44+
* another object, the behavior of this function may differ from what you are used to!
45+
* <p>
46+
* For more information see {@link #deleteById(Object)}
47+
* </p>
48+
*/
49+
@Override
50+
void delete(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 deleteAllById(Iterable<? extends ID> ids);
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 deleteAll(Iterable<? extends T> entities);
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();
2681
}

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

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,53 @@
2323
@NoRepositoryBean
2424
public interface EclipseStoreListCrudRepository<T, ID> extends ListCrudRepository<T, ID>
2525
{
26+
/**
27+
* @inheritDoc <b>Caution with referenced objects!</b><br/> If you are deleting an object that is referenced by
28+
* another object, the behavior of this function may differ from what you are used to!
29+
* <p>
30+
* For more information see {@link EclipseStoreCrudRepository#deleteById(Object)}
31+
* </p>
32+
*/
33+
@Override
34+
void deleteById(ID id);
35+
36+
/**
37+
* @inheritDoc <b>Caution with referenced objects!</b><br/> If you are deleting an object that is referenced by
38+
* another object, the behavior of this function may differ from what you are used to!
39+
* <p>
40+
* For more information see {@link EclipseStoreCrudRepository#deleteById(Object)}
41+
* </p>
42+
*/
43+
@Override
44+
void delete(T entity);
45+
46+
/**
47+
* @inheritDoc <b>Caution with referenced objects!</b><br/> If you are deleting an object that is referenced by
48+
* another object, the behavior of this function may differ from what you are used to!
49+
* <p>
50+
* For more information see {@link EclipseStoreCrudRepository#deleteById(Object)}
51+
* </p>
52+
*/
53+
@Override
54+
void deleteAllById(Iterable<? extends ID> ids);
55+
56+
/**
57+
* @inheritDoc <b>Caution with referenced objects!</b><br/> If you are deleting an object that is referenced by
58+
* another object, the behavior of this function may differ from what you are used to!
59+
* <p>
60+
* For more information see {@link EclipseStoreCrudRepository#deleteById(Object)}
61+
* </p>
62+
*/
63+
@Override
64+
void deleteAll(Iterable<? extends T> entities);
65+
66+
/**
67+
* @inheritDoc <b>Caution with referenced objects!</b><br/> If you are deleting an object that is referenced by
68+
* another object, the behavior of this function may differ from what you are used to!
69+
* <p>
70+
* For more information see {@link EclipseStoreCrudRepository#deleteById(Object)}
71+
* </p>
72+
*/
73+
@Override
74+
void deleteAll();
2675
}

spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/deletion/DeletionTest.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,23 @@
2525
import software.xdev.spring.data.eclipse.store.helper.TestUtil;
2626
import software.xdev.spring.data.eclipse.store.integration.isolated.IsolatedTestAnnotations;
2727

28-
29-
/**
30-
* These tests should show that all or most of the following keywords are available in this library: <a
31-
* href="https://docs.spring.io/spring-data/jpa/reference/repositories/query-keywords-reference.html">Repository query
32-
* keywords</a>
33-
*/
3428
@IsolatedTestAnnotations
3529
@ContextConfiguration(classes = {DeletionTestConfiguration.class})
3630
class DeletionTest
3731
{
3832
@Autowired
3933
private DeletionTestConfiguration configuration;
4034

35+
/**
36+
* JPA would throw a {@code JdbcSQLIntegrityConstraintViolationException} but it would be very expensive to search
37+
* the referencedObject in the complete object tree and throw the exception.
38+
* <p>
39+
* That is why this library simply removes the element from the repository, but if it is still referenced in
40+
* another
41+
* object, this reference is still working and pointing to the object. That means that in fact this the object to
42+
* remove could very well stay in the storage if it is referenced.
43+
* </p>
44+
*/
4145
@Test
4246
void deleteReferencedObject(
4347
@Autowired final ReferencedRepository referencedRepository,
@@ -71,9 +75,10 @@ void restoreDeletedReferencedObject(
7175
{
7276
final ReferencedDaoObject referencedObject = new ReferencedDaoObject("someValue");
7377
final ReferencingDaoObject referencingDaoObject = new ReferencingDaoObject(referencedObject);
74-
7578
referencingRepository.save(referencingDaoObject);
79+
7680
referencedRepository.delete(referencedObject);
81+
7782
referencingRepository.save(referencingDaoObject);
7883

7984
TestUtil.doBeforeAndAfterRestartOfDatastore(

0 commit comments

Comments
 (0)