1
我認爲這是一個基本問題,但我很難得到答案。jpa標準不考慮空格比較兩個字符串
問題是:使用CriteriaBuilder
和Predicate如何比較字符串而不考慮中間的空格。例如:"CH 525 kV AREIA 1077 PR"
。 CriteriaBuilder
庫中沒有「替換」功能。
cb.like(equipamento.get(EquipamentoBO_.txNomeLongo), "%" + dto.getTxNomeEquipamento().toUpperCase().replace(" ", "") + "%")
感謝
非常感謝您!那是行得通的! – danieltc07
最後的代碼是:cb.like( \t \t \t \t \t \t \t cb.upper(cb.function( 「替換」 \t \t \t,String.class \t \t \t,equipamento.get(EquipamentoBO_.txNomeLongo) \t \t \t,cb.literal( 「 」) \t \t \t,cb.literal(「」))) \t \t \t,「%」+ dto.getTxNomeEquipamento()。toUpperCase()。replace(「」,「」)+「%」 \t \t \t) – danieltc07
太好了。很高興我能幫上忙 –