Sort with ignore case

737 views
Skip to first unread message

virg...@gmail.com

unread,
Oct 3, 2013, 4:53:25 AM10/3/13
to quer...@googlegroups.com
Hello,

We have successfully used QueryDSL in our project so far and now we reached a point where the client needs to have some columns sorted with ignore case.

We couldn't find anything in particular on this matter so could you give us some hints on how to approach this issue? We looked inside the OrderSpecifier and Expression interfaces but it would be better if you could point us in the right direction.

Thanks,
Virgiliu

Timo Westkämper

unread,
Oct 3, 2013, 4:57:51 AM10/3/13
to Querydsl
Hi.

The simplest way is to use lowercase conversion:

query.orderBy(entity.property.lower().asc())

Timo

 

Thanks,
Virgiliu

--
You received this message because you are subscribed to the Google Groups "Querydsl" group.
To unsubscribe from this group and stop receiving emails from it, send an email to querydsl+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Timo Westkämper
Mysema Oy
+358 (0)40 591 2172
www.mysema.com


virg...@gmail.com

unread,
Oct 3, 2013, 5:41:11 AM10/3/13
to quer...@googlegroups.com
Dear Timo,

Thank you, it works like that and I have a follow-up question. Our sorting properties are dynamic based on some columns that a user could click in a grid.

We can definitely hard code these columns since there aren't a lot of them, but if you were to implement a generic solution, how would you do it?

Regards,
Virgiliu


On Thursday, October 3, 2013 10:57:51 AM UTC+2, Timo Westkämper wrote:
Hi.

MIke

unread,
Oct 4, 2013, 7:45:56 AM10/4/13
to quer...@googlegroups.com
Hi Timo,

thank you for your reply, we are working together with Virgiliu, and sorting is .... sorted :) .

The only problem that has arisen now is that .desc().nullsLast() is not working.... Do you have any insight on the the matter?

Thank you before hand,
Michael


On Thursday, October 3, 2013 10:57:51 AM UTC+2, Timo Westkämper wrote:
Hi.

Timo Westkämper

unread,
Oct 4, 2013, 8:05:41 AM10/4/13
to Querydsl on behalf of MIke
Hi.

Which Querydsl version, module (JPA or SQL) and database are you using?

Timo

MIke

unread,
Oct 5, 2013, 7:10:51 AM10/5/13
to quer...@googlegroups.com

query dsl last version, JPA module, Oracle DB.
although i workedaround it byt providing a second order by the uuid of the record so np with nulls.....

order by x,id.

Query dsl rocks!


On Friday, October 4, 2013 2:05:41 PM UTC+2, Timo Westkämper wrote:
Hi.

Which Querydsl version, module (JPA or SQL) and database are you using?

Timo

Timo Westkämper

unread,
Oct 5, 2013, 10:03:32 AM10/5/13
to Querydsl on behalf of MIke
Hi.

Querydsl JPA serializes nulls first and nulls last directly into the JPQL/HQL query.

If you are using Hibernate, make sure that this patch is already applied
https://github.com/hibernate/hibernate-orm/pull/415
https://hibernate.atlassian.net/browse/HHH-465

Br,
Timo
Reply all
Reply to author
Forward
0 new messages