Support expressions in SELECT and WHERE

XMLWordPrintableJSON

    • Type: New Feature
    • Resolution: Fixed
    • Priority: Major - P3
    • 1.0.0
    • Affects Version/s: None
    • Component/s: Query
    • 5
    • None
    • Needed
    • Hide

      See commit comment for summary and integration tests for all the supported shapes.

      Show
      See commit comment for summary and integration tests for all the supported shapes.
    • None
    • None
    • None
    • None
    • None
    • None

      Support computed expressions in HQL SELECT projections and WHERE predicates, translated to MongoDB aggregation expressions.

      Supported:

      • Arithmetic operators: +, , *, /, div (integer division), unary +/. Integer division truncates via $toInt($divide) ($toLong for a BIGINT result), since MongoDB's $divide always returns a double (independent of PORTABLE_INTEGER_DIVISION).
      • Criteria API operators: CriteriaBuilder.quot (behaviorally identical to /) and CriteriaBuilder.mod (-> $mod).
      • Comparison operators: >, >=, <, <=, =, <> — as a value in SELECT (e.g. select x > 1), and with computed operands in WHERE via $expr (e.g. where x + 1 > 5, where x > y).
      • Scalar predicate family as value-producing expressions (in a SELECT item or as an operand): AND/OR junctions (> $and/$or), NOT (> $not), IN list (> $in), LIKE (> $regexMatch), IS NULL / IS NOT NULL (> $eq/$ne against null, including a computed operand), BETWEEN / NOT BETWEEN (> $and of $gte/$lte bounds, negated $or of $lt/$gt; a computed operand or bound falls back to $expr, extending the compact filter form from HIBERNATE-89), and boolean fields (-> $eq against true/false).

      Out of scope (tracked separately):

      • Function calls as operands, including HQL % / mod() (rewritten to a mod() function call, unlike Criteria's mod which is the MODULO operator): HIBERNATE-196
      • CASE expressions: HIBERNATE-83

      Hibernate User Guide: https://docs.jboss.org/hibernate/orm/6.6/userguide/html_single/Hibernate_User_Guide.html#hql-expressions

            Assignee:
            Jeffrey Yemin
            Reporter:
            Jeffrey Yemin
            Almas Abdrazak
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: