OpenJPA
  1. OpenJPA
  2. OPENJPA-956 OpenJPA 2.0 iteration 5 primary task
  3. OPENJPA-967

JPA2 Query support for selction of KEY, VALUE, ENTRY of a Map value

    Details

    • Type: Sub-task Sub-task
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.0-M2
    • Fix Version/s: 2.0.0-M2
    • Component/s: None
    • Labels:
      None
    • Environment:

      Activity

      Hide
      Catalina Wei added a comment -

      The initial implementation for embeddable Map Key materialized the embeddable's owning entity,
      which from query result standpoint, is undesirable side effect.
      The revision r761851 has reworked on the support for embeddable Map Key.
      It is no longer materializing the owner entity of embeddable Map Keys.

      However, more rework is needed to move function performed in PCPath.selectEmbededMapKey() and loadEmbeddedMapKey() methods to relation's MapTableField strategies.

      Show
      Catalina Wei added a comment - The initial implementation for embeddable Map Key materialized the embeddable's owning entity, which from query result standpoint, is undesirable side effect. The revision r761851 has reworked on the support for embeddable Map Key. It is no longer materializing the owner entity of embeddable Map Keys. However, more rework is needed to move function performed in PCPath.selectEmbededMapKey() and loadEmbeddedMapKey() methods to relation's MapTableField strategies.
      Hide
      Catalina Wei added a comment -

      In evaluating support for KEY(e),
      the following JPQL queries should be considiered not valid:

      1. select e from Dept d join d.emps e where KEY(e) IS NULL

      IS NULL predicate is for evaluating association fields.
      KEY(e) can be a basic type, an embeddable class, or an entity class; KEY(e) is not an association field.

      2. select KEY(e) from Dept d join d.emps e ORDER BY KEY(e)

      The JPA2 Spec says, order item should be a state_field_path_expression; KEY(e) is not a state_field_path_expression.

      The following query is valid ; KEY(e).address.city is a state_field_path_expression:

      select KEY(e) from Dept d join d.emps ORDER BY KEY(e).address.city

      3. select COUNT(KEY(e)) from Dept d join d.emps e GROUP BY KEY(e)

      a GROUP BY item requires an aggregate function in the selection list, but
      the KEY(e) is not allowed as an argument of COUNT function.

      The following query should be valid since KEY(e).address.city is a state_field_path_expression; a valid argument to COUNT and a valid group by item:

      select COUNT(KEY(e).address.city) from Dept d join d.emps e GROUP BY KEY(e).address.city

      Show
      Catalina Wei added a comment - In evaluating support for KEY(e), the following JPQL queries should be considiered not valid: 1. select e from Dept d join d.emps e where KEY(e) IS NULL IS NULL predicate is for evaluating association fields. KEY(e) can be a basic type, an embeddable class, or an entity class; KEY(e) is not an association field. 2. select KEY(e) from Dept d join d.emps e ORDER BY KEY(e) The JPA2 Spec says, order item should be a state_field_path_expression; KEY(e) is not a state_field_path_expression. The following query is valid ; KEY(e).address.city is a state_field_path_expression: select KEY(e) from Dept d join d.emps ORDER BY KEY(e).address.city 3. select COUNT(KEY(e)) from Dept d join d.emps e GROUP BY KEY(e) a GROUP BY item requires an aggregate function in the selection list, but the KEY(e) is not allowed as an argument of COUNT function. The following query should be valid since KEY(e).address.city is a state_field_path_expression; a valid argument to COUNT and a valid group by item: select COUNT(KEY(e).address.city) from Dept d join d.emps e GROUP BY KEY(e).address.city

        People

        • Assignee:
          Catalina Wei
          Reporter:
          Catalina Wei
        • Votes:
          0 Vote for this issue
          Watchers:
          0 Start watching this issue

          Dates

          • Created:
            Updated:
            Resolved:

            Development