Interface CollectionRepository

All Superinterfaces:
CollectionTemplate, org.springframework.data.repository.Repository<Collection,Long>

@Repository public interface CollectionRepository extends org.springframework.data.repository.Repository<Collection,Long>, CollectionTemplate
The Interface CollectionRepository is used for the CRUD functionalities
Author:
karthikeyan.b02
  • Method Details

    • save

      @Caching(put=@CachePut(value="collectionCache",key="#p0.id"), evict=@CacheEvict(cacheNames={"collectionCache","collectionByBusinessCache"},allEntries=true)) Collection save(Collection collection)
      Saves a given entity. Use the returned instance for further operations as the save operation might have changed the entity instance completely.
      Parameters:
      collection - entity must not be null.
      Returns:
      the saved entity will never be null.
    • findById

      @Cacheable(cacheNames="collectionCache") Optional<Collection> findById(long id)
      Retrieves an entity by its id.
      Parameters:
      id - must not be null.
      Returns:
      the entity with the given id or Optional#empty() if none found
    • findByBusinessIdAndNameIgnoreCase

      @Query("{\'businessId\': ?0, \'name\': {$regex : \'^?1$\', $options: \'i\'}}") Optional<Collection> findByBusinessIdAndNameIgnoreCase(long businessId, String name)
    • findByIdAndBusinessId

      @Query("{ \'_id\' : ?0 , \'businessId\':?1}") @Cacheable(cacheNames="collectionByBusinessCache") Collection findByIdAndBusinessId(long id, long businessId)
      Parameters:
      id - must not be null.
      businessId - businessId to be searched with
      Returns:
      the entity with the given id or Optional#empty() if none found