3 Replies Latest reply on Aug 31, 2012 9:26 AM by Randall Hauch

    Query bug in MS3 B3?

    Chris Poulsen Newbie

      Hi,

       

      After moving our application from MS 2.8.2 to MS 3 B3 the following query construct stopped returning results:

       

      {code}

      QueryManager queryManager = session.getWorkspace().getQueryManager();

      QueryObjectModelFactory qf = queryManager.getQOMFactory();

       

      Selector textUnitSelector = qf.selector( DezideConstants.NT_TEXT_UNIT, "textUnits" );

       

      Source selector = textUnitSelector;

       

      // all columns

      Column[] columns = null;

       

      // Create the WHERE clause

      Constraint textUnitConstraint = qf.childNode( "textUnits", TEXT_UNIT_BASE_PATH );

       

      Value notDeletedVal = session.getValueFactory().createValue( false );

      Constraint notDeletedConstraint = qf.comparison( qf.propertyValue( "textUnits", DezideConstants.DELETED ),

                                                    QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO,

                                                    qf.literal(  notDeletedVal ) );

       

      Constraint constraints = qf.and( textUnitConstraint, notDeletedConstraint );

       

      // Define the orderings

      DynamicOperand oper = qf.propertyValue( "textUnits", DezideConstants.UNIT_ID );

      Ordering unitIdOrder = sortAscending?qf.ascending( oper ):qf.descending( oper );

      Ordering[] orderings = new Ordering[] { unitIdOrder };

       

      // Create the query ...

      QueryObjectModel query = qf.createQuery( selector, constraints, orderings, columns);

      query.setLimit( limit );

      query.setOffset( offset );

       

      // Execute the query and get the results ...

      QueryResult result = query.execute();

      {code}

      If I remove the "notDeletedConstraint" from the query( Constraint constraints = textUnitConstraint; ) then I get some nodes returned.

       

      Is this a bug or should the query not have worked in 2.8 in the first place?

       

      --

      Chris

        • 1. Re: Query bug in MS3 B3?
          Randall Hauch Master

          It's tough to tell offhand if this is a bug in 2.8 or 3.0 without more information. Can you please post:

           

          • the toString() of the QueryObjectModel object? It's not required, but it'd save a bit of time recreating it (especially since the above code doesn't include definitions for some of the values and constants).
          • the CND for the custom node type(s) used in the query (including any supertypes)?

           

          Best regards

          • 2. Re: Query bug in MS3 B3?
            Chris Poulsen Newbie

            Hi,

             

            Here is the QOM.toString():

             

             

            {code:sql}

            JCR-JQOM -> SELECT * FROM [author:textUnit] AS textUnits WHERE (ISCHILDNODE(textUnits,'/author/content/text') AND textUnits.[author:deleted] = CAST('false' AS BOOLEAN)) ORDER BY textUnits.[author:unitId] ASC

            AQM -> SELECT * FROM [author:textUnit] AS textUnits WHERE (ISCHILDNODE(textUnits,'/author/content/text') AND textUnits.[author:deleted] = CAST('false' AS BOOLEAN)) ORDER BY textUnits.[author:unitId] ASC LIMIT 10

            {code}

             

            The cnd file is attached.

             

            --

            Chris

            • 3. Re: Query bug in MS3 B3?
              Randall Hauch Master

              Thanks for providing that information. I don't see anything wrong with the query, so it's likely a bug in ModeShape 3's query engine. Can you log this as a bug in our JIRA?