Interface TenantRepository

  • All Superinterfaces:
    org.springframework.data.repository.CrudRepository<Tenant,​UUID>, org.springframework.data.jpa.repository.JpaRepository<Tenant,​UUID>, org.springframework.data.repository.PagingAndSortingRepository<Tenant,​UUID>, org.springframework.data.repository.query.QueryByExampleExecutor<Tenant>, org.springframework.data.repository.Repository<Tenant,​UUID>

    public interface TenantRepository
    extends org.springframework.data.jpa.repository.JpaRepository<Tenant,​UUID>
    The TenantRepository interface declares the repository for the Tenant domain type.
    Author:
    Marcus Portmann
    • Method Detail

      • addUserDirectoryToTenant

        @Modifying
        @Query(value="insert into security.user_directory_to_tenant_map(tenant_id, user_directory_id) values (:tenantId, :userDirectoryId)",
               nativeQuery=true)
        void addUserDirectoryToTenant​(@Param("tenantId")
                                      UUID tenantId,
                                      @Param("userDirectoryId")
                                      UUID userDirectoryId)
      • countByNameContainingIgnoreCase

        long countByNameContainingIgnoreCase​(String name)
      • countTenantUserDirectory

        @Query(value="select count(user_directory_id) from security.user_directory_to_tenant_map where tenant_id = :tenantId and user_directory_id = :userDirectoryId",
               nativeQuery=true)
        long countTenantUserDirectory​(@Param("tenantId")
                                      UUID tenantId,
                                      @Param("userDirectoryId")
                                      UUID userDirectoryId)
      • deleteById

        @Modifying
        @Query("delete from Tenant u where u.id = :tenantId")
        void deleteById​(@Param("tenantId")
                        UUID tenantId)
        Specified by:
        deleteById in interface org.springframework.data.repository.CrudRepository<Tenant,​UUID>
      • existsByNameIgnoreCase

        boolean existsByNameIgnoreCase​(String name)
      • findAllByOrderByNameAsc

        org.springframework.data.domain.Page<Tenant> findAllByOrderByNameAsc​(org.springframework.data.domain.Pageable pageable)
      • findAllByOrderByNameDesc

        org.springframework.data.domain.Page<Tenant> findAllByOrderByNameDesc​(org.springframework.data.domain.Pageable pageable)
      • findAllByUserDirectoryId

        @Query("select o from Tenant o join o.userDirectories as ud where ud.id = :userDirectoryId")
        List<Tenant> findAllByUserDirectoryId​(@Param("userDirectoryId")
                                              UUID userDirectoryId)
      • findByNameContainingIgnoreCaseOrderByNameAsc

        org.springframework.data.domain.Page<Tenant> findByNameContainingIgnoreCaseOrderByNameAsc​(String name,
                                                                                                  org.springframework.data.domain.Pageable pageable)
      • findByNameContainingIgnoreCaseOrderByNameDesc

        org.springframework.data.domain.Page<Tenant> findByNameContainingIgnoreCaseOrderByNameDesc​(String name,
                                                                                                   org.springframework.data.domain.Pageable pageable)
      • getNameById

        @Query("select o.name from Tenant o where o.id = :tenantId")
        Optional<String> getNameById​(@Param("tenantId")
                                     UUID tenantId)
      • getUserDirectoryIdsById

        @Query("select ud.id from UserDirectory ud join ud.tenants as o where o.id = :tenantId")
        List<UUID> getUserDirectoryIdsById​(@Param("tenantId")
                                           UUID tenantId)
      • removeUserDirectoryFromTenant

        @Modifying
        @Query(value="delete from security.user_directory_to_tenant_map where tenant_id=:tenantId and user_directory_id = :userDirectoryId",
               nativeQuery=true)
        int removeUserDirectoryFromTenant​(@Param("tenantId")
                                          UUID tenantId,
                                          @Param("userDirectoryId")
                                          UUID userDirectoryId)