replace search by example. (it caused a cryptic hibernate session error) (#3665)

This commit is contained in:
Ken Stevens 2022-06-01 15:46:44 -04:00 committed by GitHub
parent 92acd9b001
commit a3de219a1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View File

@ -31,6 +31,7 @@ import org.springframework.stereotype.Repository;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Optional;
@Repository @Repository
public interface IMdmLinkDao extends JpaRepository<MdmLink, Long>, IHapiFhirJpaRepository { public interface IMdmLinkDao extends JpaRepository<MdmLink, Long>, IHapiFhirJpaRepository {
@ -54,6 +55,9 @@ public interface IMdmLinkDao extends JpaRepository<MdmLink, Long>, IHapiFhirJpaR
")") ")")
List<MdmPidTuple> expandPidsFromGroupPidGivenMatchResult(@Param("groupPid") Long theGroupPid, @Param("matchResult") MdmMatchResultEnum theMdmMatchResultEnum); List<MdmPidTuple> expandPidsFromGroupPidGivenMatchResult(@Param("groupPid") Long theGroupPid, @Param("matchResult") MdmMatchResultEnum theMdmMatchResultEnum);
@Query("SELECT ml FROM MdmLink ml WHERE ml.mySourcePid = :sourcePid AND ml.myMatchResult = :matchResult")
Optional<MdmLink> findBySourcePidAndMatchResult(@Param("sourcePid") Long theSourcePid, @Param("matchResult") MdmMatchResultEnum theMatch);
interface MdmPidTuple { interface MdmPidTuple {
Long getGoldenPid(); Long getGoldenPid();
Long getSourcePid(); Long getSourcePid();

View File

@ -153,11 +153,7 @@ public class MdmLinkDaoSvc {
*/ */
@Transactional @Transactional
public Optional<MdmLink> getMatchedLinkForSourcePid(Long theSourcePid) { public Optional<MdmLink> getMatchedLinkForSourcePid(Long theSourcePid) {
MdmLink exampleLink = myMdmLinkFactory.newMdmLink(); return myMdmLinkDao.findBySourcePidAndMatchResult(theSourcePid, MdmMatchResultEnum.MATCH);
exampleLink.setSourcePid(theSourcePid);
exampleLink.setMatchResult(MdmMatchResultEnum.MATCH);
Example<MdmLink> example = Example.of(exampleLink);
return myMdmLinkDao.findOne(example);
} }
/** /**