英文:
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)||'%'])
非常感谢您的帮助,或者至少给出有趣资料的链接。
英文:
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.
答案1
得分: 0
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")));
英文:
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")));
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论