Package com.helixframework.db.repository
Interface GenericRepository<T,K>
- Type Parameters:
T- the type of the entityK- the type of the entity's key
public interface GenericRepository<T,K>
GenericRepository is an interface for performing generic CRUD (Create, Read, Update, Delete) operations on entities.
-
Method Summary
Modifier and TypeMethodDescriptiondefault TAdds an entity to the repository.default voidclear()Deletes all entities from the repository.default booleanDetermines if an entity exists for the given key.Finds an entity by its key.query(QuerySpecification<T> spec) Executes a query based on the given query specification.default intremove(UpdateSpecification spec) Removes entities from the repository based on the provided update specification.default voidRemoves an entity from the repository.default intupdate(UpdateSpecification spec) Updates entities in the repository based on the provided update specification.default TUpdates an entity in the repository.
-
Method Details
-
query
Executes a query based on the given query specification.- Parameters:
spec- the query specification to execute- Returns:
- a list of entities that match the query
-
find
Finds an entity by its key.- Parameters:
key- the key of the entity- Returns:
- an Optional containing the entity if found, or an empty Optional if not found
-
add
Adds an entity to the repository.- Parameters:
entity- the entity to add- Returns:
- the added entity
-
update
Updates an entity in the repository.- Parameters:
entity- the entity to be updated- Returns:
- the updated entity
-
update
Updates entities in the repository based on the provided update specification.- Parameters:
spec- the update specification defining the update criteria and data- Returns:
- the number of rows affected by the update operation
-
remove
Removes an entity from the repository.- Parameters:
entity- the entity to be deleted
-
remove
Removes entities from the repository based on the provided update specification.- Parameters:
spec- the update specification defining the criteria for the removal- Returns:
- the number of rows affected by the remove operation
-
exists
Determines if an entity exists for the given key.- Parameters:
key- the entity key
-
clear
default void clear()Deletes all entities from the repository.
-