JPA CriteriaBuilder how to create join + like query
问题 I have a SQL query: SELECT s.*, p.name, p.code FROM `stock` s LEFT JOIN product p ON s.product_id = p.id WHERE p.name LIKE "%q%" And I need to create the query using criteriabuilder I started so: CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<Long> cq = cb.createQuery(Long.class); Root<Stock> stock = cq.from(Stock.class); Path<String> path = stock.get(filter.getKey());//i have error here String likeValue = wildCard + value + wildCard; Predicate filterCondition = cb.conjunction();