具有过滤功能的Jhipster实体产生api,例如: http://localhost:8080/api/general-addresses?postalCode.contains=41
which execute sql: ............. postalCode LIKE '%41%'
http://localhost:8080/api/general-addresses?postalCode.contains=
which execute sql: ............. postalCode LIKE '%%'
Is it possible to make request with sql: LIKE '41%' ?
答案 0 :(得分:0)
您可以通过将此值添加为新条件并编写自定义规范来实现。例如,添加条件:
private String postalCodeLike;
请注意,我使用的是String而不是StringFilter。
并添加自定义规范:
if (criteria.getPostalCodeLike() != null) {
specification = specification.and((root, criteriaQuery, criteriaBuilder) ->
criteriaBuilder.like(criteriaBuilder.upper(root.join(FirstRelationedEntity_.fieldName, JoinType.INNER).join(SecondRelationedEntity_.fieldName, JoinType.INNER)
.get(Product_.postalCode)), criteria.getPostalCodeLike().toUpperCase() + "%"));
}