[英]jpa criteria compare two strings in without considering spaces
我認為這是一個基本問題,但我一直在努力尋找答案。
問題是:使用CriteriaBuilder
和Predicate如何在不考慮中間空格的情況下比較字符串。 例如: "CH 525 kV AREIA 1077 PR"
。 CriteriaBuilder
庫中沒有“替換”功能。
cb.like(equipamento.get(EquipamentoBO_.txNomeLongo), "%" + dto.getTxNomeEquipamento().toUpperCase().replace(" ", "") + "%")
謝謝
如果將REPLACE
用作要使用的函數,則可以使用一種function
方法為您解決問題:
cb.like(
cb.function("REPLACE"
, String.class
, equipamento.get(EquipamentoBO_.txNomeLongo)
, cb.literal(" ")
, cb.literal(""))
, "%" + dto.getTxNomeEquipamento().toUpperCase().replace(" ", "") + "%"
)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.