package it.enea.cruise.service.structure;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import it.enea.cruise.model.structure.ForeignKey;

public interface ForeignKeyInterface extends JpaRepository<ForeignKey, Long> {

	
	List <ForeignKey> findByTableName (String tableName);
	
	ForeignKey findByTableNameAndColumnName (String tableName, String columnName);

	List<ForeignKey> findDistinctByTableNameLikeOrTableNameLike(String tableName, String tn2);
		
	@Query("SELECT DISTINCT fk FROM ForeignKey fk WHERE fk.tableName LIKE '%_:tableName' OR fk.tableName LIKE ':tableName_%'")
	List<ForeignKey> searchTableNameLike(@Param("tableName") String tableName);

}
