掲示板
Order By Comparator
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.?
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/
10年前 に venka reddy によって更新されました。
RE: Order By Comparator
Regular Member 投稿: 231 参加年月日: 11/03/23 最新の投稿
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.
Any Suggestion on this?
9年前 に Pankaj Kathiriya によって更新されました。
RE: Order By Comparator
Liferay Master 投稿: 722 参加年月日: 10/08/05 最新の投稿
Wrtie your own comparator class and use String.CASE_INSENSITIVE_ORDER
String.CASE_INSENSITIVE_ORDER.compare(user1Name, user2Name);
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.