我有一个查询返回产品列表:
@Query(value = "Select * from Product join Product_Pro pp on Product.ID = pp.PRODUCT_ID where A_ID= ?1 order by name",
nativeQuery = true)
List<Product> findAll(long id);
如何添加 LIKE
这个条款?
当我在db a中执行此语句时,得到一个结果:
Select * from Product join Product_Pro pp on Product.ID = pp.PRODUCT_ID where A_ID= ?1 AND name LIKE '%someString%' AND content LIKE '%someString%' order by name
但我该怎么补充呢 LIKE
到我的jpa本地查询?
我试过:
@Query(value = "Select * from Product join Product_Pro pp on Product.ID = pp.PRODUCT_ID where A_ID= ?1 and name LIKE '%?%' order by name",
nativeQuery = true)
List<Product> findAll(long id, String name);
和
@Query(value = "Select * from Product join Product_Pro pp on Product.ID = pp.PRODUCT_ID where A_ID= ?1 and name LIKE '%:name%' order by name",
nativeQuery = true)
List<Product> findAll(long id,@Param("name") String name);
但这些都不管用。
1条答案
按热度按时间xmjla07d1#
我想你想
CONCAT()
: