Interface EntityRepository<T extends IdentifiableEntity>

    • 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.