Код: Выделить всё
@Entity
@Table(name = "glossary")
@Schema(description = "Glossary term")
public class Term {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Schema(accessMode = Schema.AccessMode.READ_ONLY, description = "Company ID")
private long id;
@Schema(description = "Glossary term")
private String keyword;
}
Код: Выделить всё
public static Specification hasKeywordLike(String keyword) {
return (root, query, criteriaBuilder) -> criteriaBuilder.like(criteriaBuilder.lower(root.get("keyword")), "%" + keyword.toLowerCase() + "%");
}
public static Specification hasKeywords(List keywords) {
return (root, query, criteriaBuilder) -> criteriaBuilder.lower(root.get("keyword")).in(keywords.stream().map(String::toLowerCase).toList());
}
public static Specification hasKeyword(String keyword) {
return (root, query, criteriaBuilder) -> criteriaBuilder.equal(criteriaBuilder.lower(root.get("keyword")), keyword.toLowerCase());
}
Подробнее здесь: https://stackoverflow.com/questions/791 ... f-patterns
Мобильная версия