如果引數不為空,如何在查詢中包含 IN 子句?
如果我嘗試輸入“:ramos is null”,則會出現錯誤
@Query(value = "SELECT r FROM ParceiroNegocio r "
" WHERE (:razaoSocial is null or UPPER(r.razaoSocial) LIKE CONCAT('%',UPPER(:razaoSocial),'%')) "
" AND (:nomeFantasia is null or UPPER(r.nomeFantasia) LIKE CONCAT('%',UPPER(:nomeFantasia),'%')) "
" AND (:cnpj is null or r.cnpj =:cnpj) "
" AND ((:ramos) is null or r.ramo IN (:ramos))")
Page<ParceiroNegocio> findByCnpjNomeFantasiaRazaoSocialRamoWithPagination(
@Param("razaoSocial") String razaoSocial,
@Param("nomeFantasia") String nomeFantasia,
@Param("cnpj") String cnpj,
@Param("ramos") List<Long> ramos,
Pageable pageable);
}
錯誤:
SqlExceptionHelperORA-00920: 無效的關系運算子
uj5u.com熱心網友回復:
COALESCE 幫助了我!:)
AND (COALESCE(:ramos) is null or r.ramo IN (:ramos))
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/473264.html
標籤:jpa
