Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
René Jurmann
Bug in Dynamic Query for Enterprise Edition 6 SP1 (range search)
February 22, 2011 5:40 AM
Answer

René Jurmann

Rank: Junior Member

Posts: 27

Join Date: November 15, 2010

Recent Posts

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
Ray Augé
RE: Bug in Dynamic Query for Enterprise Edition 6 SP1 (range search)
March 1, 2011 1:45 PM
Answer

Ray Augé

LIFERAY STAFF

Rank: Liferay Legend

Posts: 1171

Join Date: February 7, 2005

Recent Posts

Can you try:
1PropertyFactoryUtil.forName("data").in(accountIds)
2
3//in placed of
4
5RestrictionsFactoryUtil.in("data", accountIds)
René Jurmann
RE: Bug in Dynamic Query for Enterprise Edition 6 SP1 (range search)
March 2, 2011 2:30 AM
Answer

René Jurmann

Rank: Junior Member

Posts: 27

Join Date: November 15, 2010

Recent Posts

Hi Ray,

that still does not work.
Here as well - when I execute
1PropertyFactoryUtil.forName("data").like(accountId)

in a loop all corresponding users are found. But as soon as I want to use the range search
1PropertyFactoryUtil.forName("data").in(accountIds)

no result is returned
Vincent Vanghelle
RE: Bug in Dynamic Query for Enterprise Edition 6 SP1 (range search)
March 7, 2011 9:18 AM
Answer

Vincent Vanghelle

Rank: New Member

Posts: 3

Join Date: March 3, 2011

Recent Posts

Hi.

It looks like i have the same problem..

On 6.0.5 it was OK, then I switched to a Liferay EE SP1 version..Here is the code sample :

1DynamicQuery queryRegion = DynamicQueryFactoryUtil.forClass(ExpandoValue.class, cl);
2queryRegion.setProjection(ProjectionFactoryUtil.property("classPK"));
3queryRegion.add(RestrictionsFactoryUtil.eq("tableId",columnRegions.getTableId()));
4queryRegion.add(RestrictionsFactoryUtil.eq("columnId",columnRegions.getColumnId()));
5queryRegion.add(RestrictionsFactoryUtil.in("data", codesRegion));
6/*codesRegion = array of string, also tried with the propertyFactoryUtil.forname("data").in() method */


Doesn't work, but this one works :
1
2DynamicQuery queryRegion = DynamicQueryFactoryUtil.forClass(ExpandoValue.class, cl);
3queryRegion.setProjection(ProjectionFactoryUtil.property("classPK"));
4queryRegion.add(RestrictionsFactoryUtil.eq("tableId",columnRegions.getTableId()));
5queryRegion.add(RestrictionsFactoryUtil.eq("columnId",columnRegions.getColumnId()));
6queryRegion.add(RestrictionsFactoryUtil.eq("data",codesRegion[0]));
Vincent Vanghelle
RE: Bug in Dynamic Query for Enterprise Edition 6 SP1 (range search)
March 8, 2011 2:13 AM
Answer

Vincent Vanghelle

Rank: New Member

Posts: 3

Join Date: March 3, 2011

Recent Posts

Okey, I found this while debugging :


In class com.liferay.portal.dao.orm.hibernate.StringType :
1
2public Object getPropertyValue(Object component, int property) {
3    return null;
4}


With this method, a "in" restrictions construct a prepared statement with null values...
Aritz Galdos
RE: Bug in Dynamic Query for Enterprise Edition 6 SP1 (range search)
March 10, 2011 6:49 AM
Answer

Aritz Galdos

Rank: Expert

Posts: 401

Join Date: May 15, 2007

Recent Posts

Hi,

Has it been reported as a bug?

regards!
Vincent Vanghelle
RE: Bug in Dynamic Query for Enterprise Edition 6 SP1 (range search)
March 10, 2011 6:52 AM
Answer

Vincent Vanghelle

Rank: New Member

Posts: 3

Join Date: March 3, 2011

Recent Posts

Hi Aritz,

I haven't done anything yet, no much time (and never reported a bug on Liferay)

Where can we report this bug?
René Jurmann
RE: Bug in Dynamic Query for Enterprise Edition 6 SP1 (range search)
March 10, 2011 6:53 AM
Answer

René Jurmann

Rank: Junior Member

Posts: 27

Join Date: November 15, 2010

Recent Posts

Hi Aritz,

no, I haven't done anything like this up to now.
(Would need second logon to issues.liferay.com, correct?)

regards
René
Aritz Galdos
RE: Bug in Dynamic Query for Enterprise Edition 6 SP1 (range search)
March 10, 2011 7:54 AM
Answer

Aritz Galdos

Rank: Expert

Posts: 401

Join Date: May 15, 2007

Recent Posts

HI,

I can not report for Sp1 with my user.

I contacted Juan (Liferay Staff) and alerted him about the possible bug.

Hopefully (if it is a bug) will be solved soon.

Regards!!
Ray Augé
RE: Bug in Dynamic Query for Enterprise Edition 6 SP1 (range search)
March 21, 2011 6:36 AM
Answer

Ray Augé

LIFERAY STAFF

Rank: Liferay Legend

Posts: 1171

Join Date: February 7, 2005

Recent Posts

I just tested again with 6.0.6 CE and a simple hook, and it worked exactly as expected.

The hook is attached.
Attachments: test-dynamic-query-hook-6.0.6.1.war (5.1k)
Aritz Galdos
RE: Bug in Dynamic Query for Enterprise Edition 6 SP1 (range search)
March 21, 2011 6:51 AM
Answer

Aritz Galdos

Rank: Expert

Posts: 401

Join Date: May 15, 2007

Recent Posts

Hi Ray:

I think it affects 6.0.11 (SP1) and trunk.

AS vincent says here, there is a suspicious "return null"
Jack Daniels
RE: Bug in Dynamic Query for Enterprise Edition 6 SP1 (range search)
March 23, 2011 9:36 AM
Answer

Jack Daniels

Rank: New Member

Posts: 19

Join Date: May 17, 2010

Recent Posts

Has this been verified yet by any Liferay staff member in EE 6.0 SP1 as originally reported?

Thanks.
Aritz Galdos
RE: Bug in Dynamic Query for Enterprise Edition 6 SP1 (range search)
March 23, 2011 9:45 AM
Answer

Aritz Galdos

Rank: Expert

Posts: 401

Join Date: May 15, 2007

Recent Posts

Hi,

Seems to be a bug and I´ve been told Liferay guys are workin' on it. Surely will be solved in short.
Jack Daniels
RE: Bug in Dynamic Query for Enterprise Edition 6 SP1 (range search)
March 23, 2011 10:48 AM
Answer

Jack Daniels

Rank: New Member

Posts: 19

Join Date: May 17, 2010

Recent Posts

Thanks for the quick response Aritz, I appreciate it.

Cheers.
Igor Spasić
RE: Bug in Dynamic Query for Enterprise Edition 6 SP1 (range search)
March 25, 2011 8:27 AM
Answer

Igor Spasić

LIFERAY STAFF

Rank: New Member

Posts: 10

Join Date: April 26, 2010

Recent Posts

We filed the issue: http://issues.liferay.com/browse/LPS-16064

The core problem is in the StringType:

1public Object getPropertyValue(Object component, int property) {
2    return null;
3}


Hibernate v3.6.x uses this method when populating IN section while generating SQL. This issue was introduced when we migrated to Hibernate 3.6.0. Fix is committed to svn. For more details, please check the LPS.
parth barot
RE: Bug in Dynamic Query for Enterprise Edition 6 SP1 (range search)
April 11, 2011 10:22 PM
Answer

parth barot

Rank: Junior Member

Posts: 42

Join Date: April 30, 2010

Recent Posts

Then what is the solution for this? Do we have any patch for this? Please reply, i need this urgently..stuck at IN operator.

Thanks
parth barot
RE: Bug in Dynamic Query for Enterprise Edition 6 SP1 (range search)
April 11, 2011 10:38 PM
Answer

parth barot

Rank: Junior Member

Posts: 42

Join Date: April 30, 2010

Recent Posts

I am trying using the latest StringType in ext plugin...

http://svn.liferay.com/browse/portal/trunk/portal-impl/src/com/liferay/portal/dao/orm/hibernate/StringType.java?r1=69338&r2=76173&u=3

Thanks
Aritz Galdos
RE: Bug in Dynamic Query for Enterprise Edition 6 SP1 (range search)
April 12, 2011 12:13 AM
Answer

Aritz Galdos

Rank: Expert

Posts: 401

Join Date: May 15, 2007

Recent Posts

Hi

If you are enterprise user, you should report the incident in the tool Liferay offers to its clients.

Our client, which is enterprise client of Liferay, already got the patch for this issue from liferay.
Jack Daniels
RE: Bug in Dynamic Query for Enterprise Edition 6 SP1 (range search)
April 12, 2011 5:40 AM
Answer

Jack Daniels

Rank: New Member

Posts: 19

Join Date: May 17, 2010

Recent Posts

Too bad they only send the patch to customers that ask for it as opposed to publishing it through the customer or partner portal.

I'll have to ask for it for our EE customer as well. Thanks for mentioning this.