Hi all,
I experienced a bug within the Enterprise Edition 6 SP1.
We have following scenario:
We search for users according their attributes within the custom fields. Therefore we have added one custom field "AccountID" to the user object (using Control Panel).
In order to search for users that match a range of account IDs we use following code:
1
2String[] accountIds = ...;
3ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
4long companyId = themeDisplay.getCompanyId();
5ExpandoColumn expColumn = ExpandoColumnLocalServiceUtil.getDefaultTableColumn(companyId, User.class.getName(), "AccountID");
6Set<Long> expValueUserIds = new HashSet<Long>();
7ClassLoader cl = PortalClassLoaderUtil.getClassLoader();
8dynamicQuery = DynamicQueryFactoryUtil.forClass(ExpandoValue.class, cl);
9dynamicQuery.add(RestrictionsFactoryUtil.eq("tableId", expColumn.getTableId()));
10dynamicQuery.add(RestrictionsFactoryUtil.eq("columnId", expColumn.getColumnId()));
11dynamicQuery.add(RestrictionsFactoryUtil.in("data", accountIds));
12List<ExpandoValue> expValues = ExpandoValueLocalServiceUtil.getService().dynamicQuery(dynamicQuery);
13if(expValues != null && expValues.size() > 0){
14 for(ExpandoValue expValue : expValues){
15 expValueUserIds.add(new Long(expValue.getClassPK()));
16 }
17}
This works for the CE portal version 6.0.5 (some of our development environments are running on this version).
But when we execute this code on EE portal version 6 SP1 no result is found although some should be found.
In order to get this search to work with EE version I need to rewrite the whole coding to:
1
2String[] accountIds = ...;
3ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
4long companyId = themeDisplay.getCompanyId();
5ExpandoColumn expColumn = ExpandoColumnLocalServiceUtil.getDefaultTableColumn(companyId, User.class.getName(), "AccountID");
6Set<Long> expValueUserIds = new HashSet<Long>();
7for(int count = 0; count < accountIds.length; count++){
8 ClassLoader cl = PortalClassLoaderUtil.getClassLoader();
9 dynamicQuery = DynamicQueryFactoryUtil.forClass(ExpandoValue.class, cl);
10 dynamicQuery.add(RestrictionsFactoryUtil.eq("tableId", expColumn.getTableId()));
11 dynamicQuery.add(RestrictionsFactoryUtil.eq("columnId", expColumn.getColumnId()));
12 dynamicQuery.add(RestrictionsFactoryUtil.like("data", accountIds[count]));
13 List<ExpandoValue> expValues = ExpandoValueLocalServiceUtil.getService().dynamicQuery(dynamicQuery);
14 if(expValues != null && expValues.size() > 0){
15 for(ExpandoValue expValue : expValues){
16 expValueUserIds.add(new Long(expValue.getClassPK()));
17 }
18 }
19}
Can anyone tell me if searching for a range:
1dynamicQuery.add(RestrictionsFactoryUtil.in("data", accountIds));
works in EE version 6 SP1 and how I should configure it?
regards
René Jurmann
Bitte melden Sie sich an, um diesen Inhalt als unangebracht zu kennzeichnen.