package org.pdxfinder.rdbms.repositories;

import org.pdxfinder.rdbms.dao.MappingEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
public interface MappingEntityRepository extends JpaRepository<MappingEntity, Long> {


    MappingEntity findByMappingKey(String mappingKey);


    List<MappingEntity> findByMappedTermLabel(String mappedTermLabel);
}
@@ -82,16 +82,110 @@
 Entity;%0A
+import org.springframework.data.domain.Page;%0Aimport org.springframework.data.domain.Pageable;%0A
 import o
@@ -288,24 +288,80 @@
 tory.Query;%0A
+import org.springframework.data.repository.query.Param;%0A
 import org.s
@@ -445,16 +445,62 @@
 l.Map;%0A%0A
+%0A/**%0A * Created by abayomi on 25/07/2019.%0A */%0A
 @Reposit
@@ -647,17 +647,16 @@
 gKey);%0A%0A
-%0A
     List
@@ -718,9 +718,921 @@
 Label);%0A
+%0A%0A    @Query(value = %22Select distinct me from MappingEntity me JOIN me.mappingValues mv %22 +%0A            %22WHERE ((lower(me.entityType) = lower(:entityType)) OR :entityType = '') %22+%0A            %22AND ((KEY(mv) = :mappingLabel AND mv = :mappingValue) OR  :mappingValue = '') %22%0A    )%0A    Page%3CMappingEntity%3E findByMultipleFilters(@Param(%22entityType%22) String entityType,%0A%0A                                              @Param(%22mappingLabel%22) String mappingLabel,%0A                                              @Param(%22mappingValue%22) String mappingValue,%0A%0A                                              Pageable pageable);%0A%0A%0A%0A    @Query(value = %22select me from MappingEntity me JOIN me.mappingValues mv WHERE KEY(mv) = :dataKey AND mv = :dataValue %22)%0A    List%3CMappingEntity%3E findByAttributeAndValue(@Param(%22dataKey%22) String dataKey,%0A                                                @Param(%22dataValue%22) String dataValue);%0A%0A%0A
 %7D

Create Search Filter for the Persisted Mapping Entities