1
我有一個具有兩個屬性由「OR」操盤手「和」搜索JPA實體。這些都是ledgerCode和分裂:春天實例查詢使用「OR」
Company comp = new Company();
ExampleMatcher matcher =
ExampleMatcher.matching().withStringMatcher(StringMatcher.CONTAINING)
.withIgnoreCase("name");
comp.setCountryCode(countryCode);
comp.setLedgerCode(ledgerCode);
comp.setDivision(division);
comp.setName(name);
List<Company> result = compSearchRepository.findAll(Example.of(comp, matcher));
那麼SQL結果應該是(假設所有的參數不是null):
SELECT d
FROM COMPANY d
WHERE d.countryCode = country
OR d.ledgerCode = ledger
OR d.division = division
AND lower(d.name) LIKE '%name%'
這可能嗎?如果是,那又如何?我無法在Google上找到任何代碼示例,也無法在ExampleMatcher類中找到提示性方法名稱。
的可能的複製[怎麼做AND和在彈簧數據JPA多個OR參數的方法](http://stackoverflow.com/questions/26857501/how-to-do-and-and-multiple-or-parameters-方法合彈簧數據JPA) –