Uploaded image for project: 'Infinispan'
  1. Infinispan
  2. ISPN-5787

Issues with aggregation queries using Date objects

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 8.1.0.Alpha2, 8.0.2.Final
    • 8.0.1.Final, 8.1.0.Alpha1
    • None
    • None

    Description

      I found 2 problems, not sure if they have a common cause:

      1.
      This query

      Query q = qf.from(getModelFactory().getTransactionImplClass())
            .select("date")
            .having("date").between(makeDate("2013-02-15"), makeDate("2013-03-15")).toBuilder()
            .groupBy("date")
            .build();
      List<Object[]> list = q.list();
      

      fails with

      org.hibernate.hql.ParsingException: HQL000002: The query SELECT _gen0.date FROM org.infinispan.query.dsl.embedded.testdomain.hsearch.TransactionHS _gen0  WHERE (date >= Fri Feb 15 01:00:00 CET 2013) AND (date <= Fri Mar 15 01:00:00 CET 2013) is not valid; Parser error messages: [[statement, statementElement, selectStatement, queryExpression, querySpec, whereClause, logicalExpression, expression, logicalOrExpression, logicalAndExpression, negatedExpression, equalityExpression, relationalExpression, concatenation, additiveExpression, multiplyExpression, unaryExpression, atom]: line 1:116 mismatched token: [@35,116:118='Feb',<75>,1:116]; expecting type RIGHT_PAREN].
      

      The query works after removing the groupBy. It also partially works in remote mode (running in RemoteQueryDslConditionsTest) - the query is parsed, but still doesn't return the result as a Date object.

      2.
      This query

      Query q = qf.from(getModelFactory().getTransactionImplClass())
            .select(Expression.count("date"), Expression.min("date"))
            .having("description").eq("Hotel").toBuilder()
            .groupBy("id")
            .build();
      List<Object[]> list = q.list();
      

      returns in the 2nd column the internal representation of the Date (i.e. 20130227000000000) instead of an object. Selecting only the minimum, select(Expression.min("date")), the query returns a Date object.

      Both queries are supposed to be run inside the QueryDslConditionsTest test class.

      Attachments

        Issue Links

          Activity

            People

              anistor Adrian Nistor (Inactive)
              jmarkos Jakub Markos (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: