glassfish
  1. glassfish
  2. GLASSFISH-1606

Add an option to ReadAllQuery to allow it to return multiple references to the same result when used with fetch joining

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 9.1pe
    • Fix Version/s: not determined
    • Component/s: entity-persistence
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      1,606

      Description

      By section 4.4.5.3 of the JPA specfification:

      "A fetch join has the same join semantics as the corresponding inner or outer
      join, except that the related
      objects specified on the right-hand side of the join operation are not returned
      in the query result or otherwise
      referenced in the query. Hence, for example, if department 1 has five
      employees, the above query
      returns five references to the department 1 entity."

      Current ReadAllQuery is designed so that for the above query, only 1 reference
      to department will be returned.

      We should add a query setting that allows all five instances to be returned and
      remove the restriction in the JPQL parser that constructs a ReportQuery for
      queries returning 1 item and do a fetch join.


      In SelectNode.isReadAllQuery()

      String baseVariable = getParseTree().getFromNode().getFirstVariable();
      if (!context.isRangeVariable(baseVariable) ||
      (context.getFetchJoins(baseVariable) != null))

      { // Query's base variable is not a range variable or the base // variable has FETCH JOINs => ReportQuery return false; }

      This is important because when GLASSFISH-1519 is checked in, most queries that select
      only one attribute will be ReadAllQueries instead of ReportQueries. Because of
      the restriction on Fetch joins, it will be difficult for users to understand
      when they will get a ReadAllQuery and when they will get a ReportQuery. This
      will affect how well some of the Query hints work for them.

      (i.e. We will be able to say: If you are selecting only one thing in your
      select clause an it is an entity, the following hints will work.)

        Activity

        Hide
        tware added a comment -

        Note: The option should make the query return multiple references to the same
        instance (rather than multiple instances)

        Show
        tware added a comment - Note: The option should make the query return multiple references to the same instance (rather than multiple instances)
        Hide
        marina vatkina added a comment -

        resetting the default owner

        Show
        marina vatkina added a comment - resetting the default owner
        Hide
        ijuma added a comment -

        Adding myself to cc list.

        Show
        ijuma added a comment - Adding myself to cc list.
        Hide
        Tom Mueller added a comment -

        Bulk change to set fix version to "not determined" where the issue is open but the value is for a released version.

        Show
        Tom Mueller added a comment - Bulk change to set fix version to "not determined" where the issue is open but the value is for a released version.

          People

          • Assignee:
            tware
            Reporter:
            tware
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated: