@Repository
public interface WANRepository extends JpaRepository<WANConfiguration,Long>{
@Query("select ads from WANConfiguration as ads where ?1 BETWEEN ads.minAge AND ads.maxAge AND ads.expiryTime >?2 and ads.region=?3 and ads.gender=?4")
List<WANConfiguration> findByAllAdsForUser(Integer userAge,Date currentTime,String region, String gender);
}
這裏是調用代碼春天JPA庫:如何發送默認值參數,如果標準不匹配
List<WANConfiguration> list = fanRepository.findByAllAdsForUser(userAgeInYear, new Date(),userLocation.getRegionName(), user.getGender().name());
現在還有就是我想通過默認區域的情況下,即,用戶位置.getRegionName(),那麼我該如何做以及在數據庫和存儲庫或查詢中需要做哪些更改?
你能清楚你問的是什麼?你想在'userLocation.getRegionName()'爲空/空等時傳遞默認區域? – ByeBye
是的確實...我想通過一個默認區域,當它爲空或空 –