Try like this:
pCriteria.add(Restrictions.ilike("lastName", lLastName.toLowerCase().replaceAll('[ë]', '_')));
I am trying to make this string Micka_l
. The sign '_' stands for any character, so if you have something like Micka^l
or Mickaql
in your table you will see this records too. You can add more special french characters in square brackets like this [ëöèù]
to escape other special characters.
If you don't want to have other characters try this:
pCriteria.add(pCriteria.or(
Restrictions.eq("lastName", lLastName.toLowerCase())),
Restrictions.eq("lastName", lLastName.toLowerCase().replaceAll('[ë]', 'e'))
)
);
I assume that you input the whole word, if you don't change eq to ilike and add percent sign at the ends of the lines, like this:
pCriteria.add(pCriteria.or(
Restrictions.ilike("lastName", lLastName.toLowerCase() + "%")),
Restrictions.ilike("lastName", lLastName.toLowerCase().replaceAll('[ë]', 'e') + "%")
)
);
If there is another characters to escape you have to work around them like above.