Class AbstractTranslationService

    • Constructor Detail

      • AbstractTranslationService

        AbstractTranslationService(JpaTranslationRepository<T, ID, OWNER> repository)
        Parameters:
        repository - The JPA repository for the translation entity.
    • Method Detail

      • existsByOwnerId

         Boolean existsByOwnerId(ID ownerId)

        Finds a translation for a specific owner.

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

        Boolean indicating if the translation exists.

      • findByOwnerId

         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

         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.

      • existsByLocale

         Boolean existsByLocale(String locale)

        Checks if a translation exists for a specific locale.

        Note: This method does not require a transaction as it performs a single COUNT query.

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

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

      • existsByOwnerIdAndLocale

         Boolean existsByOwnerIdAndLocale(ID ownerId, String locale)

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

        Note: This method does not require a transaction as it performs a single COUNT query.

        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.

      • findByOwnerIdAndLocale

         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.

      • findByNameAndLocale

         List<T> findByNameAndLocale(String name, String locale)

        Finds all translations with a specific name and locale.

        Override this method if the translation entity does not have a 'name' field.

        Parameters:
        name - The name to search for in translations.
        locale - The locale of the translation.
        Returns:

        List of translations.

      • save

         T save(T translation)

        Saves a translation entity.

        Parameters:
        translation - The translation entity to save.
        Returns:

        The saved translation entity.

      • deleteByOwnerIdAndLocale

         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.
        Returns:

        The number of deleted translations (usually 0 or 1).

      • deleteByLocale

         Integer deleteByLocale(String locale)

        Deletes all translations for a specific locale.

        Parameters:
        locale - The locale of the translations to delete.
        Returns:

        The number of deleted translations.