【发布时间】:2021-05-13 14:30:49
【问题描述】:
您好,这是连接品牌名称、标题和下标题的查询
@Query(value="SELECT c FROM ProductOption c WHERE cast( c.id AS string ) like %:search% or CONCAT(COALESCE(c.product.brand.name,''),' ',c.product.title,' ',c.underTitle) like %:search%")
Page<ProductOption> findAllBySearch(String search,Pageable pageable);
但是每次brand为空时,productoption都不包含在响应中..
基本上我想要的是连接品牌名称、标题和下标题,如果品牌不为空,如果它为空,则按标题和下标题连接..
我已经尝试了更多使用 CASE etd 的方法...
【问题讨论】:
标签: jpa spring-data-jpa jpql