Interface JpaTranslationRepository

  • All Implemented Interfaces:
    org.springframework.data.jpa.repository.JpaRepository , org.springframework.data.repository.CrudRepository , org.springframework.data.repository.ListCrudRepository , org.springframework.data.repository.ListPagingAndSortingRepository , org.springframework.data.repository.PagingAndSortingRepository , org.springframework.data.repository.Repository , org.springframework.data.repository.query.QueryByExampleExecutor

    @NoRepositoryBean() 
    public interface JpaTranslationRepository<T extends ITranslation<ID, OWNER>, ID extends Object, OWNER extends Object>
     implements JpaRepository<T, ID>
                        

    Repository interface for translatable entities. This interface extends the JpaRepository interface and provides methods for working with translatable entities.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      abstract Boolean existsByLocale(String locale) Checks if a translation exists for a specific locale.
      abstract Boolean existsByOwnerId(ID ownerId) Finds all translations for a specific owner.
      abstract Boolean existsByOwnerIdAndLocale(ID ownerId, String locale) Checks if a translation exists for a specific owner and locale.
      abstract List<T> findByOwnerId(ID ownerId) Finds all translations for a specific owner by its ID.
      abstract Page<T> findByOwnerId(ID ownerId, Pageable pageable) Finds all translations for a specific owner by its ID, with pagination.
      abstract T findByOwnerIdAndLocale(ID ownerId, String locale) Finds a translation for a specific owner and locale.
      abstract Integer deleteByLocale(String locale) Deletes all translations for a specific locale.
      abstract Integer deleteByOwnerIdAndLocale(ID ownerId, String locale) Deletes a translation for a specific owner and locale.
      • Methods inherited from class org.springframework.data.repository.CrudRepository

        count, delete, deleteAll, deleteAll, deleteAllById, deleteById, existsById, findById, save
      • Methods inherited from class org.springframework.data.repository.ListCrudRepository

        findAll, findAllById, saveAll
      • Methods inherited from class org.springframework.data.jpa.repository.JpaRepository

        deleteAllByIdInBatch, deleteAllInBatch, deleteAllInBatch, deleteInBatch, findAll, findAll, flush, getById, getOne, getReferenceById, saveAllAndFlush, saveAndFlush
      • Methods inherited from class org.springframework.data.repository.ListPagingAndSortingRepository

        findAll
      • Methods inherited from class org.springframework.data.repository.PagingAndSortingRepository

        findAll
      • Methods inherited from class org.springframework.data.repository.query.QueryByExampleExecutor

        count, exists, findAll, findBy, findOne
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail

      • existsByLocale

        @Query(value = "
                SELECT CASE WHEN COUNT(t) > 0 THEN TRUE ELSE FALSE END 
                FROM #{#entityName} t WHERE t.locale = :locale
                ") abstract Boolean existsByLocale(String locale)

        Checks if a translation exists for a specific locale.

        Parameters:
        locale - The locale to check for.
        Returns:

        True if at least one translation with the given locale exists, false otherwise.

      • existsByOwnerId

        @Query(value = "SELECT t FROM #{#entityName} t WHERE t.locale = :locale") abstract Boolean existsByOwnerId(ID ownerId)

        Finds all translations for a specific owner.

        Parameters:
        ownerId - ID The locale to filter by.
        Returns:

        Boolean indicating if the translation exists.

      • existsByOwnerIdAndLocale

        @Query(value = "
                SELECT CASE WHEN COUNT(t) > 0 THEN TRUE ELSE FALSE END 
                FROM #{#entityName} t WHERE t.owner.id = :ownerId AND t.locale = :locale
                ") abstract Boolean existsByOwnerIdAndLocale(ID ownerId, String locale)

        Checks if a translation exists for a specific owner and locale.

        Parameters:
        ownerId - The ID of the owner entity.
        locale - The locale to check for.
        Returns:

        True if a translation exists for the owner and locale, false otherwise.

      • findByOwnerId

        @Query(value = "SELECT t FROM #{#entityName} t WHERE t.owner.id = :ownerId") abstract List<T> findByOwnerId(ID ownerId)

        Finds all translations for a specific owner by its ID.

        Parameters:
        ownerId - The ID of the owner entity.
        Returns:

        List of translations for the owner.

      • findByOwnerId

        @Query(value = "SELECT t FROM #{#entityName} t WHERE t.owner.id = :ownerId") abstract Page<T> findByOwnerId(ID ownerId, Pageable pageable)

        Finds all translations for a specific owner by its ID, with pagination.

        Parameters:
        ownerId - The ID of the owner entity.
        pageable - Pagination information.
        Returns:

        Page of translations for the owner.

      • findByOwnerIdAndLocale

        @Query(value = "SELECT t FROM #{#entityName} t WHERE t.owner.id = :ownerId AND t.locale = :locale") abstract T findByOwnerIdAndLocale(ID ownerId, String locale)

        Finds a translation for a specific owner and locale.

        Parameters:
        ownerId - The ID of the owner entity.
        locale - The locale of the translation.
        Returns:

        The translation, or null if not found.

      • deleteByLocale

        @Modifying()@Query(value = "DELETE FROM #{#entityName} t WHERE t.locale = :locale") abstract Integer deleteByLocale(String locale)

        Deletes all translations for a specific locale.

        Parameters:
        locale - The locale of the translations to delete.
      • deleteByOwnerIdAndLocale

        @Modifying()@Query(value = "DELETE FROM #{#entityName} t WHERE t.owner.id = :ownerId AND t.locale = :locale") abstract Integer deleteByOwnerIdAndLocale(ID ownerId, String locale)

        Deletes a translation for a specific owner and locale.

        Parameters:
        ownerId - The ID of the owner entity.
        locale - The locale of the translation to delete.