Tribune

Home » Liferay Portal » English » 3. Development

Vista Combinata Vista Piatta Vista ad Albero
Discussioni [ Precedente | Successivo ]
René Jurmann
Bug in Dynamic Query for Enterprise Edition 6 SP1 (range search)
22 febbraio 2011 5.40
Risposta

René Jurmann

Punteggio: Junior Member

Messaggi: 27

Data di Iscrizione: 15 novembre 2010

Messaggi recenti

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)
1 marzo 2011 13.45
Risposta

Ray Augé

LIFERAY STAFF

Punteggio: Liferay Legend

Messaggi: 1195

Data di Iscrizione: 7 febbraio 2005

Messaggi recenti

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)
2 marzo 2011 2.30
Risposta

René Jurmann

Punteggio: Junior Member

Messaggi: 27

Data di Iscrizione: 15 novembre 2010

Messaggi recenti

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)
7 marzo 2011 9.18
Risposta

Vincent Vanghelle

Punteggio: New Member

Messaggi: 3

Data di Iscrizione: 3 marzo 2011

Messaggi recenti

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)
8 marzo 2011 2.13
Risposta

Vincent Vanghelle

Punteggio: New Member

Messaggi: 3

Data di Iscrizione: 3 marzo 2011

Messaggi recenti

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)
10 marzo 2011 6.49
Risposta

Aritz Galdos

Punteggio: Expert

Messaggi: 405

Data di Iscrizione: 15 maggio 2007

Messaggi recenti

Hi,

Has it been reported as a bug?

regards!
Vincent Vanghelle
RE: Bug in Dynamic Query for Enterprise Edition 6 SP1 (range search)
10 marzo 2011 6.52
Risposta

Vincent Vanghelle

Punteggio: New Member

Messaggi: 3

Data di Iscrizione: 3 marzo 2011

Messaggi recenti

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)
10 marzo 2011 6.53
Risposta

René Jurmann

Punteggio: Junior Member

Messaggi: 27

Data di Iscrizione: 15 novembre 2010

Messaggi recenti

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)
10 marzo 2011 7.54
Risposta

Aritz Galdos

Punteggio: Expert

Messaggi: 405

Data di Iscrizione: 15 maggio 2007

Messaggi recenti

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)
21 marzo 2011 6.36
Risposta

Ray Augé

LIFERAY STAFF

Punteggio: Liferay Legend

Messaggi: 1195

Data di Iscrizione: 7 febbraio 2005

Messaggi recenti

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

The hook is attached.
Allegati: 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)
21 marzo 2011 6.51
Risposta

Aritz Galdos

Punteggio: Expert

Messaggi: 405

Data di Iscrizione: 15 maggio 2007

Messaggi recenti

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)
23 marzo 2011 9.36
Risposta

Jack Daniels

Punteggio: New Member

Messaggi: 19

Data di Iscrizione: 17 maggio 2010

Messaggi recenti

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)
23 marzo 2011 9.45
Risposta

Aritz Galdos

Punteggio: Expert

Messaggi: 405

Data di Iscrizione: 15 maggio 2007

Messaggi recenti

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)
23 marzo 2011 10.48
Risposta

Jack Daniels

Punteggio: New Member

Messaggi: 19

Data di Iscrizione: 17 maggio 2010

Messaggi recenti

Thanks for the quick response Aritz, I appreciate it.

Cheers.
Igor Spasić
RE: Bug in Dynamic Query for Enterprise Edition 6 SP1 (range search)
25 marzo 2011 8.27
Risposta

Igor Spasić

LIFERAY STAFF

Punteggio: New Member

Messaggi: 10

Data di Iscrizione: 26 aprile 2010

Messaggi recenti

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)
11 aprile 2011 22.22
Risposta

parth barot

Punteggio: Junior Member

Messaggi: 42

Data di Iscrizione: 30 aprile 2010

Messaggi recenti

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)
11 aprile 2011 22.38
Risposta

parth barot

Punteggio: Junior Member

Messaggi: 42

Data di Iscrizione: 30 aprile 2010

Messaggi recenti

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)
12 aprile 2011 0.13
Risposta

Aritz Galdos

Punteggio: Expert

Messaggi: 405

Data di Iscrizione: 15 maggio 2007

Messaggi recenti

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)
12 aprile 2011 5.40
Risposta

Jack Daniels

Punteggio: New Member

Messaggi: 19

Data di Iscrizione: 17 maggio 2010

Messaggi recenti

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.