How to ignore accents when querying string paths?

2,932 views
Skip to first unread message

Jonathan Rodrigues de Oliveira

unread,
Oct 1, 2015, 11:24:57 AM10/1/15
to Querydsl

There is some way to ignore accents on queries?

Example: I have a person named as "José" in my database. I want to my query do return that person accepting "jose" or "josé" as parameter for the name:

JPQLQuery query = new JPAQuery(entityManager);
query.from(person);
query.where(person.name.likeIgnoreAccents("jose"));

How can I do this?
Thanks.

Message has been deleted

timowest

unread,
Oct 1, 2015, 11:41:37 AM10/1/15
to Querydsl
This is not supported directly on the JPA level. What database do you use and how would you express that on the SQL level?

Jonathan Rodrigues de Oliveira

unread,
Oct 1, 2015, 7:20:21 PM10/1/15
to Querydsl
I'm using Postgresql and I would use the "unaccent" function.

Jonathan Rodrigues de Oliveira

unread,
Oct 17, 2015, 10:30:20 AM10/17/15
to Querydsl
Any idea on this?


On Thursday, October 1, 2015 at 12:41:37 PM UTC-3, timowest wrote:

timowest

unread,
Oct 18, 2015, 2:04:21 PM10/18/15
to Querydsl
You can do that using JPA 2.1 SQL function invocations:

StringExpression expr = Expressions.stringTemplate("FUNCTION('unaccent', {0})", str);

where str is the original expression and expr the resulting unaccent invocation.
Reply all
Reply to author
Forward
0 new messages