package ai.decompile.analysis.model.repository;

import ai.decompile.analysis.model.entity.StaticString;
import java.util.List;
import java.util.UUID;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

public interface StaticStringRepository extends JpaRepository<StaticString, UUID> {
  List<StaticString> findByAnalysisIdOrderByAddressAsc(UUID analysisId);

  @Query(
      "SELECT s FROM StaticString s WHERE s.analysis.id = :analysisId AND LOWER(s.value) LIKE LOWER(CONCAT('%', :pattern, '%'))")
  List<StaticString> searchByValue(
      @Param("analysisId") UUID analysisId, @Param("pattern") String pattern);
}
