Fórumok
Order By Comparator
venka reddy, módosítva 10 év-val korábban
Order By Comparator
Regular Member Bejegyzések: 231 Csatlakozás dátuma: 2011.03.23. Legújabb bejegyzések
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, módosítva 10 év-val korábban
RE: Order By Comparator
Expert Bejegyzések: 483 Csatlakozás dátuma: 2010.07.31. Legújabb bejegyzések
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, módosítva 10 év-val korábban
RE: Order By Comparator
Regular Member Bejegyzések: 231 Csatlakozás dátuma: 2011.03.23. Legújabb bejegyzések
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, módosítva 9 év-val korábban
RE: Order By Comparator
Regular Member Bejegyzések: 231 Csatlakozás dátuma: 2011.03.23. Legújabb bejegyzések
Any Suggestion on this?
Pankaj Kathiriya, módosítva 9 év-val korábban
RE: Order By Comparator
Liferay Master Bejegyzések: 722 Csatlakozás dátuma: 2010.08.05. Legújabb bejegyzések
Wrtie your own comparator class and use String.CASE_INSENSITIVE_ORDER
String.CASE_INSENSITIVE_ORDER.compare(user1Name, user2Name);
venka reddy, módosítva 9 év-val korábban
RE: Order By Comparator
Regular Member Bejegyzések: 231 Csatlakozás dátuma: 2011.03.23. Legújabb bejegyzések
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.