//使用regexp_like //正则 Expression regExpr = cb.literal("(^|\\s|\\w)(" + MIsnumberUtils.toString(localContactPk) + ")($|\\s|\\w)"); //ROOT,数据库列 Expression path = root.get("name"); Expression regExprLike = cb.function("regexp_like",Boolean.class,path,regExpr); //1表示匹配 0相反 Predicate localCOntact= cb.equal(regExprLike,1); //Oracle Expression regExpr = cb.literal("(^|\\s|\\w)(" + MISNumberUtils.toString(localContactPk) + ")($|\\s|\\w)"); //ROOT,数据库列 Expression path = root.get("name"); Expression regExprInstr = cb.function("regexp_instr",Integer.class,path,regExpr); //结果必须大于0 Predicate localCOntact= cb.gt(regExprInstr,0); //实例 Expression regExpr = criteriaBuilder.literal("(补贴|农业)"); Expression regExprLike = criteriaBuilder.function("regexp_like",Boolean.class,root.get("title"),regExpr); // predicate= criteriaBuilder.and(predicate,criteriaBuilder.equal(regExprLike,1));
关注"都市百货" 了解南陵
微信咨询wanglf2r(不拉群 发广告者勿加)
热门评论