Nuxeo 5.6 to 5.8 - boolean values processing in NXQL bug or change?

I have a standard Content View based on NXQL query.

I want an optional criteria in the query, coming from a seam bean property. In this particular case, it is a flag to show or hide obsolete objects.

Here is the query:

SELECT * FROM Document WHERE ecm:currentLifeCycleState = 'approved' 
OR ( ecm:currentLifeCycleState = 'deleted' AND ? = 1 )

? parameter is mapped to a boolean property in a bean.

This query works in 5.6, not in 5.8 (tested with HF03).

Is it a bug or a behavior change? Any other approaches to implement this?

ERROR STACK:

Caused by: org.nuxeo.ecm.core.api.ClientException: Failed to execute query: null
    at org.nuxeo.ecm.core.api.AbstractSession.query(AbstractSession.java:1625)
    at org.nuxeo.ecm.core.api.AbstractSession.query(AbstractSession.java:1501)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.nuxeo.ecm.core.api.TransactionalCoreSessionWrapper.invoke(TransactionalCoreSessionWrapper.java:136)
    at com.sun.proxy.$Proxy89.query(Unknown Source)
    at org.nuxeo.ecm.automation.core.operations.document.Query.run(Query.java:44)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.nuxeo.ecm.automation.core.impl.InvokableMethod.doInvoke(InvokableMethod.java:135)
    at org.nuxeo.ecm.automation.core.impl.InvokableMethod.invoke(InvokableMethod.java:149)
    ... 84 more
Caused by: java.lang.NullPointerException
    at org.nuxeo.ecm.core.storage.sql.jdbc.NXQLQueryMaker$WhereBuilder.getColumnInfo(NXQLQueryMaker.java:1447)
    at org.nuxeo.ecm.core.storage.sql.jdbc.NXQLQueryMaker$WhereBuilder.visitExpression(NXQLQueryMaker.java:1624)
    at org.nuxeo.ecm.core.query.sql.model.Expression.accept(Expression.java:42)
    at org.nuxeo.ecm.core.query.sql.model.DefaultQueryVisitor.visitExpression(DefaultQueryVisitor.java:103)
    at org.nuxeo.ecm.core.storage.sql.jdbc.NXQLQueryMaker$WhereBuilder.visitExpression(NXQLQueryMaker.java:1665)
    at org.nuxeo.ecm.core.query.sql.model.Expression.accept(Expression.java:42)
    at org.nuxeo.ecm.core.query.sql.model.DefaultQueryVisitor.visitExpression(DefaultQueryVisitor.java:103)
    at org.nuxeo.ecm.core.storage.sql.jdbc.NXQLQueryMaker$WhereBuilder.visitExpression(NXQLQueryMaker.java:1665)
    at org.nuxeo.ecm.core.query.sql.model.Expression.accept(Expression.java:42)
    at org.nuxeo.ecm.core.storage.sql.jdbc.NXQLQueryMaker$WhereBuilder.visitMultiExpression(NXQLQueryMaker.java:1584)
    at org.nuxeo.ecm.core.query.sql.model.MultiExpression.accept(MultiExpression.java:40)
    at org.nuxeo.ecm.core.storage.sql.jdbc.NXQLQueryMaker.buildQuery(NXQLQueryMaker.java:455)
    at org.nuxeo.ecm.core.storage.sql.jdbc.JDBCMapper.query(JDBCMapper.java:750)
    at org.nuxeo.ecm.core.storage.sql.SoftRefCachingMapper.query(SoftRefCachingMapper.java:101)
    at org.nuxeo.ecm.core.storage.sql.SessionImpl.query(SessionImpl.java:1254)
    at org.nuxeo.ecm.core.storage.sql.ra.ConnectionImpl.query(ConnectionImpl.java:368)
    at org.nuxeo.ecm.core.storage.sql.coremodel.SQLSession$SQLSessionQuery.execute(SQLSession.java:611)
    at org.nuxeo.ecm.core.api.AbstractSession.query(AbstractSession.java:1571)
    ... 98 more
0 votes

2 answers

2711 views

ANSWER

Has nobody else run into this issue?
12/16/2013

Hi,

I've perform the request "select * from document where 1=1" in NXQL research at the bottom of advanced research page in a Nuxeo5.6 and 5.8, and yes: it works on a 5.6 and return an error in 5.8 ("Failed to execute query: null") => it's a reproductible issue.

But is it a bug or a feature :-), I don't know.

It is not yet a problem for us (we have our owns, which prevents us to go on nuxeo 5.8; so we're waiting), but one day maybe…

12/16/2013

Thanks for your input.

Waiting for nuxeo guys' feedback.

Any alternative implementation or a not too cumbersome bypass would be welcome! :)

12/16/2013

Well, it's very ugly and probably too cumbersome, but in your case (yes, it can work only with your NXQL request, but it's my only idea for the moment) is to replace your '?' by ecm:currentLifeCycleState and 1 by '?' . Return 'deleted' instead 1, so it becomes : … (ecm:currentLifeCycleState = 'deleted' AND ecm:currentLifeCycleState = ? )

I've look for NXQL documentation for a standard property independent of a perticular document but I didn't found.

Another way, is to create a value with a fixed default value on all your documents (easiest to use your own type of Document, with your schema), so you can have a foo schema and a bar metadata at 1, and test your bean property against it (foo:bar = ?). I just tested on 5.6 and 5.8, a NXQL request with a where condition on our own schema and it works, but with is only possible if you are not yet in production, and may induce important changes.

So, I hope Nuxeo guys could help you with better solution.

12/16/2013



This has been fixed for Nuxeo 5.8-HF06 and Nuxeo 5.9.2, cf NXP-13658.

0 votes



Thank you.
02/03/2014


Thanks a lot for your responses manuek!

The solutions/hints you've mentionned made me do more testing and I've noticed a curious combination that works.

In the “A = B” clause:

  • the value-flag coming from seam bean put on the right position
  • on the left position put the term ecm:isVersion that works in my case giving the constant “1” as I don't use versionning on these particular doc types :) (still pretty ugly, huh, and dangerous)

So, a temporary hack-solution looks like:

SELECT * FROM Document WHERE ecm:currentLifeCycleState = 'approved' 
OR ( ecm:currentLifeCycleState = 'deleted' AND ecm:isVersion = ? )

This allows me to keep the structure of the query - having a criteria with it's activation flag along - waiting for the bug fix.

Could nuxeo guys confirm that this is a bug and open an issue? Thanks.

0 votes