/
NoSQLRepository.java
80 lines (71 loc) · 3.03 KB
/
NoSQLRepository.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
* Copyright (c) 2024 Contributors to the Eclipse Foundation
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Apache License v2.0 which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php.
*
* You may elect to redistribute this code under either of these licenses.
*
* Contributors:
*
* Otavio Santana
*/
package org.eclipse.jnosql.mapping;
import jakarta.data.repository.BasicRepository;
import jakarta.data.repository.CrudRepository;
import jakarta.data.repository.Delete;
import java.util.stream.Stream;
/**
* Interface for NoSQL repositories, providing additional operations beyond basic {@link BasicRepository}.
*
* @param <T> the type of the entity managed by this repository
* @param <K> the type of the entity's primary key
*/
public interface NoSQLRepository<T, K> extends BasicRepository<T, K>, CrudRepository<T, K>{
/**
* Deletes all persistent entities of the primary entity type that are managed by the repository.
*
* @throws UnsupportedOperationException for Key-Value and Wide-Column databases that are not capable of the {@code deleteAll} operation.
*/
@Delete
void deleteAll();
/**
* Retrieves the total number of persistent entities of the specified type in the database.
*
* @return the total number of entities.
* @throws UnsupportedOperationException for Key-Value and Wide-Column databases that are not capable of the {@code count} operation.
*/
long countBy();
/**
* Returns whether an entity with the given Id exists.
*
* @param id must not be {@code null}.
* @return {@code true} if an entity with the given Id exists, {@code false} otherwise.
* @throws NullPointerException when the Id is {@code null}.
*/
boolean existsById(K id);
/**
* Returns all instances of the type {@code T} with the given Ids.
* <p>
* If some or all Ids are not found, no entities are returned for these Ids.
* <p>
* Note that the order of elements in the result is not guaranteed.
*
* @param ids must not be {@code null} nor contain any {@code null} values.
* @return guaranteed to be not {@code null}. The size can be equal or less than the number of given
* ids.
* @throws NullPointerException in case the given {@link Iterable ids} or one of its items is {@code null}.
*/
Stream<T> findByIdIn(Iterable<K> ids);
/**
* Deletes all instances of the type {@code T} with the given Ids.
* <p>
* Entities that are not found in the persistent store are silently ignored.
*
* @param ids must not be {@code null}. Must not contain {@code null} elements.
* @throws NullPointerException when the iterable is {@code null} or contains {@code null} elements.
*/
void deleteByIdIn(Iterable<K> ids);
}