Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-15362

An XWQL query that selects from an object property fails when using the advanced query parameter API

    XMLWordPrintable

Details

    • Bug
    • Resolution: Solved By
    • Major
    • None
    • 10.3
    • Old Core, Query
    • Easy

    Description

      You can reproduce with the following code:

      {{velocity}}
      #set ($statement = 'from doc.object(XWiki.XWikiUsers) as user where user.first_name like :input')
      $services.query.xwql($statement).bindValue('input').literal('ad').anyChars().query().execute()
      {{/velocity}}
      

      It works if I use:

      $services.query.xwql($statement).bindValue('input', 'ad%').execute()
      

      The stack trace ends with:

      Caused by: java.lang.RuntimeException: Invalid HQL query [ select doc.fullName from XWikiDocument as doc , BaseObject as user , com.xpn.xwiki.objects.StringProperty as user_first_name1 where ( user_first_name1.value like :input ) and doc.fullName=user.name and user.className='XWiki.XWikiUsers' and user_first_name1.id.id=user.id and user_first_name1.id.name='first_name' ]
      	at org.xwiki.query.internal.EscapeLikeParametersQuery.getStatement(EscapeLikeParametersQuery.java:121)
      	at com.xpn.xwiki.store.hibernate.query.HqlQueryExecutor.createHibernateQuery(HqlQueryExecutor.java:220)
      	at com.xpn.xwiki.store.hibernate.query.HqlQueryExecutor$1.doInHibernate(HqlQueryExecutor.java:183)
      	at com.xpn.xwiki.store.hibernate.query.HqlQueryExecutor$1.doInHibernate(HqlQueryExecutor.java:178)
      	at com.xpn.xwiki.store.XWikiHibernateBaseStore.execute(XWikiHibernateBaseStore.java:921)
      	... 186 more
      Caused by: net.sf.jsqlparser.JSQLParserException
      	at net.sf.jsqlparser.parser.CCJSqlParserUtil.parse(CCJSqlParserUtil.java:55)
      	at org.xwiki.query.internal.EscapeLikeParametersQuery.modifyStatement(EscapeLikeParametersQuery.java:138)
      	at org.xwiki.query.internal.EscapeLikeParametersQuery.getStatement(EscapeLikeParametersQuery.java:119)
      	... 190 more
      Caused by: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "." "."
          at line 1, column 92.
      
      Was expecting one of:
      
          ","
          ";"
          "ACTION"
          "ANY"
          "AS"
          "CASCADE"
          "CAST"
          "COLUMN"
          "COMMIT"
          "CONNECT"
          "CROSS"
          "DO"
          "ENABLE"
          "END"
          "EXCEPT"
          "EXTRACT"
          "FIRST"
          "FOLLOWING"
          "FOR"
          "FULL"
          "GROUP"
          "HAVING"
          "INDEX"
          "INNER"
          "INSERT"
          "INTERSECT"
          "JOIN"
          "KEY"
          "LAST"
          "LEFT"
          "MATERIALIZED"
          "MINUS"
          "NATURAL"
          "NO"
          "NULLS"
          "OPEN"
          "ORDER"
          "OVER"
          "PARTITION"
          "PERCENT"
          "PIVOT"
          "PRECISION"
          "PRIMARY"
          "PRIOR"
          "RANGE"
          "REPLACE"
          "RIGHT"
          "ROW"
          "ROWS"
          "SEPARATOR"
          "SIBLINGS"
          "START"
          "TABLE"
          "TEMP"
          "TEMPORARY"
          "TRUNCATE"
          "UNION"
          "UNSIGNED"
          "VALUE"
          "VALUES"
          "WHERE"
          "XML"
          <EOF>
          <K_DATETIMELITERAL>
          <S_CHAR_LITERAL>
          <S_IDENTIFIER>
          <S_QUOTED_IDENTIFIER>
      
      	at net.sf.jsqlparser.parser.CCJSqlParser.generateParseException(CCJSqlParser.java:18047)
      	at net.sf.jsqlparser.parser.CCJSqlParser.jj_consume_token(CCJSqlParser.java:17900)
      	at net.sf.jsqlparser.parser.CCJSqlParser.Statement(CCJSqlParser.java:91)
      	at net.sf.jsqlparser.parser.CCJSqlParserUtil.parse(CCJSqlParserUtil.java:53)
      	... 192 more
      

      Attachments

        Issue Links

          Activity

            People

              tmortagne Thomas Mortagne
              mflorea Marius Dumitru Florea
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: