Package com.espacogeek.geek.repositories
Interface MediaRepository
- All Superinterfaces:
org.springframework.data.repository.CrudRepository<MediaModel,,Integer> org.springframework.data.jpa.repository.JpaRepository<MediaModel,,Integer> org.springframework.data.repository.ListCrudRepository<MediaModel,,Integer> org.springframework.data.repository.ListPagingAndSortingRepository<MediaModel,,Integer> org.springframework.data.repository.PagingAndSortingRepository<MediaModel,,Integer> org.springframework.data.repository.query.QueryByExampleExecutor<MediaModel>,org.springframework.data.repository.Repository<MediaModel,Integer>
@Repository
public interface MediaRepository
extends org.springframework.data.jpa.repository.JpaRepository<MediaModel,Integer>
-
Method Summary
Modifier and TypeMethodDescriptionBatch-loads the company association for a collection of MediaModel entities.Batch-loads the genre association for a collection of MediaModel entities.Batch-loads the people association for a collection of MediaModel entities.org.springframework.data.domain.Page<MediaModel> findMediaByNameOrAlternativeTitleAndMediaCategory(String name, String alternativeTitle, Integer category, org.springframework.data.domain.Pageable pageable) Finds media by matching name or alternative title within a specific media category.org.springframework.data.domain.Page<MediaModel> findMediaByNameOrAlternativeTitleAndMediaCategoryIn(String name, String alternativeTitle, Collection<Integer> categories, org.springframework.data.domain.Pageable pageable) Finds media by matching name or alternative title within multiple media categories.findOneMediaByExternalReferenceAndTypeReference(String reference, TypeReferenceModel typeReference) Find Media by ExternalReference and TypeReference.Methods inherited from interface org.springframework.data.repository.CrudRepository
count, delete, deleteAll, deleteAll, deleteAllById, deleteById, existsById, findById, saveMethods inherited from interface org.springframework.data.jpa.repository.JpaRepository
deleteAllByIdInBatch, deleteAllInBatch, deleteAllInBatch, deleteInBatch, findAll, findAll, flush, getById, getOne, getReferenceById, saveAllAndFlush, saveAndFlushMethods inherited from interface org.springframework.data.repository.ListCrudRepository
findAll, findAllById, saveAllMethods inherited from interface org.springframework.data.repository.ListPagingAndSortingRepository
findAllMethods inherited from interface org.springframework.data.repository.PagingAndSortingRepository
findAllMethods inherited from interface org.springframework.data.repository.query.QueryByExampleExecutor
count, exists, findAll, findBy, findOne
-
Method Details
-
findMediaByNameOrAlternativeTitleAndMediaCategory
@Query("SELECT m FROM MediaModel m WHERE m.mediaCategory.id = :category AND ( m.name LIKE CONCAT(\'%\', :name, \'%\') OR EXISTS ( SELECT 1 FROM AlternativeTitleModel a WHERE a.media = m AND a.name LIKE CONCAT(\'%\', :alternativeTitle, \'%\') ))") org.springframework.data.domain.Page<MediaModel> findMediaByNameOrAlternativeTitleAndMediaCategory(@Param("name") String name, @Param("alternativeTitle") String alternativeTitle, @Param("category") Integer category, @PageableDefault(size=10,page=0) org.springframework.data.domain.Pageable pageable) Finds media by matching name or alternative title within a specific media category. This query searches for MediaModel entities where the name or any alternative title matches the provided name or alternativeTitle parameters. It filters the results to only include those within the specified media category.- Parameters:
name- The name of the media to search for.alternativeTitle- The alternative title of the media to search for.category- The ID of the media category to filter results by.pageable- Pagination information.- Returns:
- A list of MediaModel objects that match the search criteria.
-
findMediaByNameOrAlternativeTitleAndMediaCategoryIn
@Query("SELECT m FROM MediaModel m WHERE m.mediaCategory.id IN :categories AND ( m.name LIKE CONCAT(\'%\', :name, \'%\') OR EXISTS ( SELECT 1 FROM AlternativeTitleModel a WHERE a.media = m AND a.name LIKE CONCAT(\'%\', :alternativeTitle, \'%\') ))") org.springframework.data.domain.Page<MediaModel> findMediaByNameOrAlternativeTitleAndMediaCategoryIn(@Param("name") String name, @Param("alternativeTitle") String alternativeTitle, @Param("categories") Collection<Integer> categories, @PageableDefault(size=10,page=0) org.springframework.data.domain.Pageable pageable) Finds media by matching name or alternative title within multiple media categories.- Parameters:
name- The name of the media to search for.alternativeTitle- The alternative title of the media to search for.categories- The IDs of the media categories to filter results by.pageable- Pagination information.- Returns:
- A page of MediaModel objects that match the search criteria.
-
findOneMediaByExternalReferenceAndTypeReference
@Query("SELECT m FROM MediaModel m JOIN ExternalReferenceModel e ON e MEMBER OF m.externalReference WHERE e.reference = :reference AND e.typeReference = :typeReference") Optional<MediaModel> findOneMediaByExternalReferenceAndTypeReference(@Param("reference") String reference, @Param("typeReference") TypeReferenceModel typeReference) Find Media by ExternalReference and TypeReference.- Parameters:
typeReference-externalReference-- Returns:
- a Optional of MediaModel.
-
findAllWithGenreByMediaIn
@Query("SELECT DISTINCT m FROM MediaModel m LEFT JOIN FETCH m.genre WHERE m IN :medias") List<MediaModel> findAllWithGenreByMediaIn(@Param("medias") Collection<MediaModel> medias) Batch-loads the genre association for a collection of MediaModel entities. Used by @BatchMapping to resolve the N+1 problem for genres.- Parameters:
medias- the collection of MediaModel entities to load genres for.- Returns:
- a list of MediaModel entities with their genre collections initialized.
-
findAllWithCompanyByMediaIn
@Query("SELECT DISTINCT m FROM MediaModel m LEFT JOIN FETCH m.company WHERE m IN :medias") List<MediaModel> findAllWithCompanyByMediaIn(@Param("medias") Collection<MediaModel> medias) Batch-loads the company association for a collection of MediaModel entities. Used by @BatchMapping to resolve the N+1 problem for companies.- Parameters:
medias- the collection of MediaModel entities to load companies for.- Returns:
- a list of MediaModel entities with their company collections initialized.
-
findAllWithPeopleByMediaIn
@Query("SELECT DISTINCT m FROM MediaModel m LEFT JOIN FETCH m.people WHERE m IN :medias") List<MediaModel> findAllWithPeopleByMediaIn(@Param("medias") Collection<MediaModel> medias) Batch-loads the people association for a collection of MediaModel entities. Used by @BatchMapping to resolve the N+1 problem for people.- Parameters:
medias- the collection of MediaModel entities to load people for.- Returns:
- a list of MediaModel entities with their people collections initialized.
-