package com.iqser.red.service.persistence.management.v1.processor.service.persistence.repository;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import com.iqser.red.service.persistence.management.v1.processor.entity.dossier.FileAttributeEntity;

public interface FileAttributesRepository extends JpaRepository<FileAttributeEntity, String> {

    @Modifying(flushAutomatically = true, clearAutomatically = true)
    @Query("DELETE FROM FileAttributeEntity f where f.fileAttributeId.fileAttributeConfigId = :fileAttributeConfigId")
    void deleteByFileAttributeConfigId(String fileAttributeConfigId);


    @Modifying(flushAutomatically = true, clearAutomatically = true)
    @Query("DELETE FROM FileAttributeEntity f where f.fileAttributeId.fileId = :fileId")
    void deleteByFileId(String fileId);


    @Query("SELECT f FROM FileAttributeEntity f where f.fileAttributeId.fileId = :fileId")
    List<FileAttributeEntity> findByFileId(String fileId);

}
