Jhipster 如何搜索以开头的字段?
Jhipster实体与过滤一起生成api,例如:Jhipster 如何搜索以开头的字段?,jhipster,Jhipster,Jhipster实体与过滤一起生成api,例如: 您可以通过添加此值作为新标准并编写自定义规范来实现这一点。例如,添加标准: private String postalCodeLike; 请注意,我使用的是String而不是StringFilter 并添加自定义规范: if (criteria.getPostalCodeLike() != null) { specification = specification.and((root, criteriaQuery, criteri
您可以通过添加此值作为新标准并编写自定义规范来实现这一点。例如,添加标准:
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() + "%"));
}
您必须通过修改JHipster生成的代码手动对其进行编码。
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() + "%"));
}