predicates.add(builder.or(builder.like(expression, "%" + vals[0] + "%"),builder.like(expression,"%"+vals[1]+"%"),.......));
builder.or裡面有多個builder.like, vals是一個數組,怎麼用for循環往builder.or裡
面添加,才能達到我想要的效果,也就是對應的SQL為:select * from xx where name
like '%王%’or name like '%李%' or name like '%高%' or ......
已解決:
String[] str = value.split(",");
List predicateList = new ArrayList();
Predicate [] p = new Predicate[str.length];
for(int i = 0; i < str.length; i++){
predicateList.add(builder.like(expression, "%" + str[i] + "%"));
}
predicateList.toArray(p);
predicates.add(builder.or(p));