Interface EntityRepository<T extends IdentifiableEntity>
-
- All Known Subinterfaces:
CalendarEventOccurrenceRepository
,CalendarEventRepository
,CalendarRepository
,DelayedNotificationDataRepository
,DocumentPermalinkRepository
,DownloadDetailRepository
,ExternalAccountRepository
,NotificationResourceDataRepository
,PersistentResourceTokenRepository
,PersonalizationRepository
,QuotaRepository
,ReminderRepository
,SPGroupRepository
,SPUserRepository
,TicketRepository
,VariableScheduledValueRepository
,VariablesRepository
,VersionPermalinkRepository
- All Known Implementing Classes:
AbstractJpaEntityRepository
,BasicJpaEntityRepository
,ContributionTrackingRepository
,DefaultCalendarEventOccurrenceRepository
,DefaultCalendarEventRepository
,DefaultCalendarRepository
,DefaultReminderRepository
,DefaultVariableScheduledValueRepository
,DefaultVariablesRepository
,DelayedNotificationDataJpaRepository
,DelayedNotificationUserSettingJpaRepository
,DocumentPermalinkJpaRepository
,DownloadDetailJpaRepository
,ErrorRepository
,ExternalAccountJpaRepository
,HistoryStepRepository
,NotificationResourceDataJpaRepository
,PdcAxisValueRepository
,PdcClassificationRepository
,PersistentResourceDateReminderRepository
,PersistentResourceTokenJPARepository
,PersonalizationJPARepository
,POPUPMessageBeanRepository
,ProcessInstanceRepository
,QuotaJPARepository
,RatingRepository
,ReplacementRepository
,ServerMessageBeanRepository
,SILVERMAILMessageBeanRepository
,SilverpeasJpaEntityRepository
,SPGroupJpaRepository
,SPUserJpaRepository
,TicketJpaRepository
,UserSettingsRepository
,VersionPermalinkJpaRepository
public interface EntityRepository<T extends IdentifiableEntity>
A repository storing the entities managed or handled by Silverpeas. All entities that are stored into such a repository are persisted over the runtime and then can be retrieved later.When an entity is stored into a repository, its unique identifier is then no more its local and temporary OID (Object IDentifier) that is usually the address of its location in the memory but a unique and permanent identifier that is usually its identifier in the persistence context backed by the repository. This last identifier is then set when the entity is stored into the repository.
The repository isn't just a simple DAO (Data Access Object) to access the whole or some of the entities properties but it is a business object from which entities are persisted and retrieved. That means the persistence of the entities should be handled only through business operations provided by the repository, each of them having a specific business meaning, and these operations should return the entity in its completeness. The fetching of some of the entity's relationships should be done through the repositories corresponding to the entities related by the relationships.
- Author:
- mmoquillon
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description boolean
contains(T entity)
Does this repository contains the specified entity?void
delete(List<T> entities)
Deletes entities.default void
delete(T... entity)
Deletes entities.default long
deleteByComponentInstanceId(String componentInstanceId)
Deletes all entities belonging to the specified component instance.default long
deleteById(String... ids)
Deletes entities by their ids.long
deleteById(Collection<String> ids)
Deletes entities by their ids.SilverpeasList<T>
findByCriteria(QueryCriteria criteria)
Finds all the entities that match the specified criteria.void
flush()
Synchronizes the persistence context to the underlying data source.SilverpeasList<T>
getAll()
Gets all the persisted entities.T
getById(String id)
Gets a persisted entity by its unique identifier.default SilverpeasList<T>
getById(String... ids)
Gets persisted entities by their ids.SilverpeasList<T>
getById(Collection<String> ids)
Gets persisted entities by their ids.SilverpeasList<T>
save(List<T> entities)
Persists entities : create (if id is null or empty) or update.default T
save(T entity)
Persists entity : create (if id is null or empty) or update.default SilverpeasList<T>
save(T... entities)
Persists entities : create (if id is null or empty) or update.
-
-
-
Method Detail
-
getAll
SilverpeasList<T> getAll()
Gets all the persisted entities. WARNING: we don't recommend to use this method with a lot of persisted entities.- Returns:
- a list of all the persisted entities.
-
getById
T getById(String id)
Gets a persisted entity by its unique identifier.- Parameters:
id
- a unique identifier.- Returns:
- the entity with the specified entity identifier or null if no such entity exist in the data source.
-
getById
default SilverpeasList<T> getById(String... ids)
Gets persisted entities by their ids.- Parameters:
ids
- the unique identifiers of the entity to get.- Returns:
- a list of entities.
-
getById
SilverpeasList<T> getById(Collection<String> ids)
Gets persisted entities by their ids.- Parameters:
ids
- the unique identifiers of the entity to get.- Returns:
- a list of entities.
-
findByCriteria
SilverpeasList<T> findByCriteria(QueryCriteria criteria)
Finds all the entities that match the specified criteria.- Parameters:
criteria
- the criteria constraining the query and for which the entities to list have to satisfy.- Returns:
- a list of entities matching the specified criteria. If a pagination criterion is
defined in the criteria, then the returned list is a
PaginationList
instance.
-
save
default T save(T entity)
Persists entity : create (if id is null or empty) or update.- Parameters:
entity
- the entity to save.- Returns:
- the created or updated entity.
-
save
default SilverpeasList<T> save(T... entities)
Persists entities : create (if id is null or empty) or update.- Parameters:
entities
- the entities to save.- Returns:
- the created or updated entity.
-
save
SilverpeasList<T> save(List<T> entities)
Persists entities : create (if id is null or empty) or update.- Parameters:
entities
- the entities to save.- Returns:
- the created or updated entity.
-
delete
default void delete(T... entity)
Deletes entities.- Parameters:
entity
- the entity/entities to delete.
-
delete
void delete(List<T> entities)
Deletes entities.- Parameters:
entities
- the entities to delete.
-
deleteById
default long deleteById(String... ids)
Deletes entities by their ids.- Parameters:
ids
- the identifiers of the entities to delete.- Returns:
- number of deleted entities.
-
deleteById
long deleteById(Collection<String> ids)
Deletes entities by their ids.- Parameters:
ids
- the identifiers of the entities to delete.- Returns:
- number of deleted entities.
-
deleteByComponentInstanceId
default long deleteByComponentInstanceId(String componentInstanceId)
Deletes all entities belonging to the specified component instance.- Parameters:
componentInstanceId
- the unique component instance identifier.- Returns:
- the number of deleted entities.
-
flush
void flush()
Synchronizes the persistence context to the underlying data source. Within a transactional context, the persistence context is directly put to the data source but will be effective only when the transaction will be committed. The consequence of the synchronization within a transaction context is the persistence context is then validated by the data source. Making it work, the data source has to support the transactions.Warning, the behavior of this method is implementation-dependent. According to the type of the repository or of the underlying data source, the flush can not to be working.
-
contains
boolean contains(T entity)
Does this repository contains the specified entity? It contains the entity if its persistence context is taken in charge by the instances of the repository class.- Parameters:
entity
- an entity.- Returns:
- true if the specified entity exists in the persistence context backed by this repository, false otherwise.
-
-