Cara, na boa, eu não to conseguindo fazer nada com o seu código.
Matcher.START e Matcher.ANYWHERE não exstem, o q existe é matcher.start() q não é statico.
o seu código
c.add( Restrictions.or(
Restrictions.ilike( "commandName", 'xxxxx', Matcher.START),
Restrictions.ilike( "commandName", 'yyyy', Matcher.ANYWHERE)
));
funciona para dois itens muito bem! Mas e para 3? Tenho uma lista ai qd adiciono o terceiro item ficará um código assim
String queryInputTwo = null;
if(0 < temp.length) {
queryInput = temp[0];
}
int i = 0;
while(i < temp.length) {
if(i==0) {
i++;
}
if(i < temp.length) {
queryInputTwo = temp[i];
}
criteria.add( Restrictions.or(
Restrictions.ilike( field, PERCENT_SIGN + queryInput + PERCENT_SIGN, MatchMode.START),
Restrictions.ilike( field, PERCENT_SIGN + queryInputTwo + PERCENT_SIGN, MatchMode.ANYWHERE)));
i++;
queryInput = queryInputTwo;
}
ou
int i = 0;
while(i < temp.length) {
queryInput = temp[i];
criteria.add( Restrictions.or(
Restrictions.ilike( field, PERCENT_SIGN + queryInput + PERCENT_SIGN),
Restrictions.ilike( field, null)));
i++;
}
O hibernate coloca AND entre os OR, ainda não funciona
Deve ter algum método que eu não sei usar, algo assim.