package ru.soune.nocopy.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import ru.soune.nocopy.entity.file.ImageHashEntity;

import java.util.List;

@Repository
public interface ImageHashRepository extends JpaRepository<ImageHashEntity, String> {
    void deleteByFileId(String fileId);
    ImageHashEntity findByFileId(String fileId);
    ImageHashEntity findByHash64HiAndHash64Lo(Long hash64Hi, Long hash64Lo);
    @Modifying
    @Transactional
    @Query("DELETE FROM ImageHashEntity i WHERE i.file.id IN :fileIds")
    void deleteAllByFileIdIn(@Param("fileIds") List<String> fileIds);
}
