Fórum
Order By Comparator
venka reddy, modificado 10 Anos atrás.
Order By Comparator
Regular Member Postagens: 231 Data de Entrada: 23/03/11 Postagens Recentes
Hi,
I am using the Order By Comparator to reterive the results in Sorting so i have used as below
OrderByComparator orderByComparator =OrderByComparatorFactoryUtil.create("User_",orderByCol, orderByType.equals("asc"));
But it is returning the results in case-sensitive(differentiating between capital and lower-case letters).
How can i make to return the results considering the capitla and lower case are equal.?
I am using the Order By Comparator to reterive the results in Sorting so i have used as below
OrderByComparator orderByComparator =OrderByComparatorFactoryUtil.create("User_",orderByCol, orderByType.equals("asc"));
But it is returning the results in case-sensitive(differentiating between capital and lower-case letters).
How can i make to return the results considering the capitla and lower case are equal.?
Harish Kumar, modificado 10 Anos atrás.
RE: Order By Comparator
Expert Postagens: 483 Data de Entrada: 31/07/10 Postagens Recentes
you can make use of compareToIgnoreCase method.
http://liferayzone.wordpress.com/2012/06/14/liferay-search-container-orderable-columns/
http://liferayzone.wordpress.com/2012/06/14/liferay-search-container-orderable-columns/
venka reddy, modificado 10 Anos atrás.
RE: Order By Comparator
Regular Member Postagens: 231 Data de Entrada: 23/03/11 Postagens Recentes
hi Harish,
Thanks for reply,
Actually my implementation is as follows
Here I am using the User table to sort the entities so i have used OrderByComparator orderByComparator =OrderByComparatorFactoryUtil. create ("User_",orderByCol, orderByType . equals("asc"));.
Here is the method i am using
List<User> userList = UserLocalServiceUtil.search(companyId ,-,-,-,-,-,-,-, orderByComparator);
Here I am getting the results with sorting as below
Ex:
Actual Results :
ABC
DEF
YUI
abc
ghj
But the excepted results are:
ABC
abc
DEF
ghj
YUI
I am Struck here, Any Suggestions to get the results with case-sensitive.?
here i don't want to use any custom class extending comparator.
Thanks for reply,
Actually my implementation is as follows
Here I am using the User table to sort the entities so i have used OrderByComparator orderByComparator =OrderByComparatorFactoryUtil. create ("User_",orderByCol, orderByType . equals("asc"));.
Here is the method i am using
List<User> userList = UserLocalServiceUtil.search(companyId ,-,-,-,-,-,-,-, orderByComparator);
Here I am getting the results with sorting as below
Ex:
Actual Results :
ABC
DEF
YUI
abc
ghj
But the excepted results are:
ABC
abc
DEF
ghj
YUI
I am Struck here, Any Suggestions to get the results with case-sensitive.?
here i don't want to use any custom class extending comparator.
venka reddy, modificado 9 Anos atrás.
RE: Order By Comparator
Regular Member Postagens: 231 Data de Entrada: 23/03/11 Postagens Recentes
Any Suggestion on this?
Pankaj Kathiriya, modificado 9 Anos atrás.
RE: Order By Comparator
Liferay Master Postagens: 722 Data de Entrada: 05/08/10 Postagens Recentes
Wrtie your own comparator class and use String.CASE_INSENSITIVE_ORDER
String.CASE_INSENSITIVE_ORDER.compare(user1Name, user2Name);
venka reddy, modificado 9 Anos atrás.
RE: Order By Comparator
Regular Member Postagens: 231 Data de Entrada: 23/03/11 Postagens Recentes
Hi Pankaj,
Thanks for the reply
I don't want to use the comparator for some reasons.
Here I am using the dynamic query to retrieve the entries, so reterving and sorting will be at shot. so I am using the "OrderByComparator"
where i can included in the dynamic query as below
OrderByComparator comparator =OrderByComparatorFactoryUtil.create("User_",orderByCol, orderByType.equals("asc"))
userList = UserLocalServiceUtil.dynamicQuery(userQuery,start,end,comparator);
Also i have tried as below no luck.
if(orderByType.equalsIgnoreCase("asc")) {
dynamicQuery.addOrder(OrderFactoryUtil.asc(orderByCol));
}else {
dynamicQuery.addOrder(OrderFactoryUtil.desc(orderByCol));
}
userList = UserLocalServiceUtil.dynamicQuery(userQuery,start,end);
Is there any other option to retrieve the entries as case-senstive using dynamic query only.
Thanks for the reply
I don't want to use the comparator for some reasons.
Here I am using the dynamic query to retrieve the entries, so reterving and sorting will be at shot. so I am using the "OrderByComparator"
where i can included in the dynamic query as below
OrderByComparator comparator =OrderByComparatorFactoryUtil.create("User_",orderByCol, orderByType.equals("asc"))
userList = UserLocalServiceUtil.dynamicQuery(userQuery,start,end,comparator);
Also i have tried as below no luck.
if(orderByType.equalsIgnoreCase("asc")) {
dynamicQuery.addOrder(OrderFactoryUtil.asc(orderByCol));
}else {
dynamicQuery.addOrder(OrderFactoryUtil.desc(orderByCol));
}
userList = UserLocalServiceUtil.dynamicQuery(userQuery,start,end);
Is there any other option to retrieve the entries as case-senstive using dynamic query only.