Package com.alpaca.persistence
Interface IGenericDAO<T,ID>
- Type Parameters:
T- The type of entity.ID- The type of the entity's identifier.
- All Known Subinterfaces:
IAdvertiserDAO,IPermissionDAO,IProfileDAO,IRoleDAO,IUserDAO
- All Known Implementing Classes:
AdvertiserDAOImpl,GenericDAOImpl,PermissionDAOImpl,ProfileDAOImpl,RoleDAOImpl,UserDAOImpl
public interface IGenericDAO<T,ID>
Generic Data Access Object (DAO) interface providing common CRUD operations.
-
Method Summary
Modifier and TypeMethodDescriptionvoiddeleteById(ID id) Deletes an entity by its identifier - must not be null.booleanexistsAllByIds(Collection<ID> ids) Checks if multiple entities exist by their identifiers.booleanexistsById(ID id) Checks if an entity exists by its identifier.booleanChecks if an entity exists based on its unique properties.findAll()Retrieves all entities.findAllByIds(Collection<ID> ids) Finds all entities by their identifiers.org.springframework.data.domain.Page<T> findAllPage(org.springframework.data.domain.Pageable pageable) Retrieves all entities with pagination support.Finds an entity by its identifier.Saves a new entity.saveAll(Collection<T> t) Saves multiple entities in batch.updateById(T t, ID id) Updates an entity by its identifier.
-
Method Details
-
findById
Finds an entity by its identifier.- Parameters:
id- The identifier of the entity - must not be null.- Returns:
- An
Optionalcontaining the entity if found, otherwise empty.
-
findAllByIds
Finds all entities by their identifiers.- Parameters:
ids- A collection of entity identifiers - must not be null.- Returns:
- A list of entities found.
-
updateById
Updates an entity by its identifier.- Parameters:
t- The updated entity data - must not be null.id- The identifier of the entity to update - must not be null.- Returns:
- The updated entity.
-
save
Saves a new entity.- Parameters:
t- The entity to save - must not be null.- Returns:
- The saved entity.
-
saveAll
Saves multiple entities in batch.- Parameters:
t- A collection of entities to save - must not be null.- Returns:
- A list of saved entities.
-
deleteById
Deletes an entity by its identifier - must not be null.- Parameters:
id- The identifier of the entity to delete.
-
findAll
Retrieves all entities.- Returns:
- A list of all entities.
-
findAllPage
org.springframework.data.domain.Page<T> findAllPage(org.springframework.data.domain.Pageable pageable) Retrieves all entities with pagination support.- Parameters:
pageable- The pagination configuration - must not be null.- Returns:
- A
Pagecontaining the paginated entities.
-
existsById
Checks if an entity exists by its identifier.- Parameters:
id- The identifier of the entity - must not be null.- Returns:
trueif the entity exists, otherwisefalse.
-
existsAllByIds
Checks if multiple entities exist by their identifiers.- Parameters:
ids- A collection of entity identifiers - must not be null.- Returns:
trueif all entities exist, otherwisefalse.
-
existsByUniqueProperties
Checks if an entity exists based on its unique properties.- Parameters:
t- The entity containing unique properties to check - must not be null.- Returns:
trueif an entity with the same unique properties exists, otherwisefalse.
-