select * from db_object o where o.value not like all (array ['%'||chr(32)||chr(32)||'%', '%'||chr(9)||'%', '%'||chr(10)||'%', '%'||chr(13)||'%'])
Hello everyone, i dont now how to change sql request in CriteriaBuilder. I am stuck on this line:
where o.value not like all (array ['%'||chr(32)||chr(32)||'%', '%'||chr(9)||'%', '%'||chr(10)||'%', '%'||chr(13)||'%'])
I will be very grateful for your help or at least links to interesting material.
Advertisement
Answer
maybe to someone helps
CriteriaBuilder builder = session.getCriteriaBuilder(); CriteriaQuery<BaseObject> criteria = builder.createQuery(BaseObject.class); Root<BaseObject> rootCriteria = criteria.from(BaseObject.class); List<Predicate> criteriaList = new ArrayList<>(); criteriaList.add(builder.like(rootCriteria.get("value"), "% %")); criteriaList.add(builder.like(rootCriteria.get("value"), "%n%")); criteriaList.add(builder.like(rootCriteria.get("value"), "%t%")); criteriaList.add(builder.like(rootCriteria.get("value"), "%r%")); criteria.select(rootCriteria).where( builder.or(criteriaList.toArray(new Predicate[criteriaList.size()])) ).orderBy(builder.asc(rootCriteria.get("objectId")));