将 sql 翻译成 criteriaBuilder
translate sql to criteriaBuilder
select *
from db_object o
where o.value not like all (array ['%'||chr(32)||chr(32)||'%', '%'||chr(9)||'%', '%'||chr(10)||'%', '%'||chr(13)||'%'])
大家好,我现在不知道如何在 CriteriaBuilder 中更改 sql 请求。我被困在这条线上:
where o.value not like all (array ['%'||chr(32)||chr(32)||'%', '%'||chr(9)||'%', '%'||chr(10)||'%', '%'||chr(13)||'%'])
我将非常感谢您的帮助或至少链接到有趣的 material。
也许对某人有帮助
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")));
select *
from db_object o
where o.value not like all (array ['%'||chr(32)||chr(32)||'%', '%'||chr(9)||'%', '%'||chr(10)||'%', '%'||chr(13)||'%'])
大家好,我现在不知道如何在 CriteriaBuilder 中更改 sql 请求。我被困在这条线上:
where o.value not like all (array ['%'||chr(32)||chr(32)||'%', '%'||chr(9)||'%', '%'||chr(10)||'%', '%'||chr(13)||'%'])
我将非常感谢您的帮助或至少链接到有趣的 material。
也许对某人有帮助
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")));