From 3307a5f14c6d5ae00612d35a8fede3fdca061c14 Mon Sep 17 00:00:00 2001 From: AnuragVanam Date: Sat, 27 Mar 2021 16:39:34 -0400 Subject: [PATCH] Update issue#133 --- src/main/java/com/gw/database/HostRepository.java | 7 ++++--- src/main/java/com/gw/database/ProcessRepository.java | 5 +++-- src/main/java/com/gw/database/WorkflowRepository.java | 5 +++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/gw/database/HostRepository.java b/src/main/java/com/gw/database/HostRepository.java index 5219e8b41..51a3ecf49 100644 --- a/src/main/java/com/gw/database/HostRepository.java +++ b/src/main/java/com/gw/database/HostRepository.java @@ -5,18 +5,19 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.query.Param; import com.gw.jpa.Host; public interface HostRepository extends CrudRepository{ - @Query(value="select * from hosts where owner = ?1 ", + @Query(value="select * from host where owner = ?1 ", nativeQuery = true) Collection findByOwner(String owner); - @Query(value="select * from hosts where name like '%?1%'", + @Query(value="select * from HOST where name like CONCAT('%',:keyword,'%')", nativeQuery = true) - Collection findHostsByNameAlike(String keyword); + Collection findHostsByNameAlike(@Param("keyword") String keyword); diff --git a/src/main/java/com/gw/database/ProcessRepository.java b/src/main/java/com/gw/database/ProcessRepository.java index 7ed4d74d0..a2cc64d0c 100644 --- a/src/main/java/com/gw/database/ProcessRepository.java +++ b/src/main/java/com/gw/database/ProcessRepository.java @@ -4,15 +4,16 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.query.Param; import com.gw.jpa.GWProcess; import com.gw.jpa.Host; public interface ProcessRepository extends CrudRepository{ - @Query(value = "select * from GWProcess where name like '%?1%'", + @Query(value = "select * from GWProcess where name like CONCAT('%',:keyword,'%')", nativeQuery = true) - Collection findProcessesByNameAlike(String keyword); + Collection findProcessesByNameAlike(@Param("keyword") String keyword); @Query(value="select * from gwprocess where description = 'python'", nativeQuery = true) diff --git a/src/main/java/com/gw/database/WorkflowRepository.java b/src/main/java/com/gw/database/WorkflowRepository.java index 14e104041..4dd3ba3ad 100644 --- a/src/main/java/com/gw/database/WorkflowRepository.java +++ b/src/main/java/com/gw/database/WorkflowRepository.java @@ -4,14 +4,15 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.query.Param; import com.gw.jpa.GWProcess; import com.gw.jpa.Workflow; public interface WorkflowRepository extends CrudRepository{ - @Query(value="select * from workflow where name like '%?1%'", + @Query(value="select * from workflow where name like CONCAT('%',:keyword,'%')", nativeQuery=true) - Collection findProcessesByNameAlike(String keyword); + Collection findProcessesByNameAlike(@Param("keyword") String keyword); }