001package ca.uhn.fhir.jpa.dao.data;
002
003import ca.uhn.fhir.jpa.model.entity.ResourceTable;
004import ca.uhn.fhir.jpa.model.entity.SearchParamPresentEntity;
005import org.springframework.data.jpa.repository.JpaRepository;
006import org.springframework.data.jpa.repository.Modifying;
007import org.springframework.data.jpa.repository.Query;
008import org.springframework.data.repository.query.Param;
009
010import java.util.List;
011
012/*
013 * #%L
014 * HAPI FHIR JPA Server
015 * %%
016 * Copyright (C) 2014 - 2022 Smile CDR, Inc.
017 * %%
018 * Licensed under the Apache License, Version 2.0 (the "License");
019 * you may not use this file except in compliance with the License.
020 * You may obtain a copy of the License at
021 *
022 * http://www.apache.org/licenses/LICENSE-2.0
023 *
024 * Unless required by applicable law or agreed to in writing, software
025 * distributed under the License is distributed on an "AS IS" BASIS,
026 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
027 * See the License for the specific language governing permissions and
028 * limitations under the License.
029 * #L%
030 */
031
032public interface ISearchParamPresentDao extends JpaRepository<SearchParamPresentEntity, Long>, IHapiFhirJpaRepository {
033
034        @Query("SELECT s FROM SearchParamPresentEntity s WHERE s.myResource = :res")
035        List<SearchParamPresentEntity> findAllForResource(@Param("res") ResourceTable theResource);
036
037        @Modifying
038        @Query("delete from SearchParamPresentEntity t WHERE t.myResourcePid = :resid")
039        void deleteByResourceId(@Param("resid") Long theResourcePid);
040
041}