我有包含不同表的数据库。如果满足某些条件,我正在尝试从表电子邮件中获取电子邮件。条件之一是来自广告表的广告名称(作为参数)必须包含来自适当广告表的适当广告的文本。我无法在这种情况下正常工作(所有其他条件都可以正常工作)。
@Query( "SELECT e.email FROM SuitableAd sad " +
"JOIN sad.author a JOIN a.email e " +
"WHERE :name LIKE '%sad.text%'" +
" AND (:price BETWEEN sad.priceFrom AND priceTo) AND sad.category = :category")
List<String> findBySuitableAd(@Param("name") String name, @Param("price")BigDecimal price, @Param("category")
String category);
答案 0 :(得分:0)
尝试这个
@Query( "SELECT e.email FROM SuitableAd sad " +
"JOIN sad.author a JOIN a.email e " +
"WHERE sad.text LIKE '%:name%'" +
" AND (:price BETWEEN sad.priceFrom AND priceTo) AND sad.category = :category")
列表findBySuitableAd(@Param(“ name”)字符串名称,@Param(“ price”)BigDecimal价格,@Param(“ category”) 字符串类别);