glassfish
  1. glassfish
  2. GLASSFISH-187

EJB QL: Queries with Fetch Join are not yet working

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 9.0pe
    • Fix Version/s: 9.0pe_dev
    • Component/s: entity-persistence
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: Sun

    • Issuezilla Id:
      187

      Description

      Queries using FETCH JOINs throw QueryException.

      SELECT c from Customer c JOIN FETCH c.spouse

      Local Exception Stack:
      Exception [TOPLINK-6044] (Oracle TopLink Essentials - 10g release 4 (10.1.4.0.0)
      (Build 060116Dev)): oracle.toplink.essentials.exceptions.QueryException
      Exception Description: The primary key read from the row [DatabaseRecord(
      CUSTOMER_TABLE.ID => 1
      CUSTOMER_TABLE.NAME => MyName
      CUSTOMER_TABLE.FK5_FOR_CUSTOMER_TABLE => 2
      CUSTOMER_TABLE.CODE => USA
      CUSTOMER_TABLE.COUNTRY => United States
      CUSTOMER_TABLE.FK6_FOR_CUSTOMER_TABLE => 1)] during the execution of the
      query was detected to be null. Prima
      ry keys must not contain null.
      Query:
      ReadObjectQuery(com.sun.ts.tests.ejb30.persistence.query.language.schema30.Spouse)
      at
      oracle.toplink.essentials.exceptions.QueryException.nullPrimaryKeyInBuildingObject(QueryException.java:785)
      at
      oracle.toplink.essentials.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:349)
      at
      oracle.toplink.essentials.mappings.OneToOneMapping.valueFromRowInternalWithJoin(OneToOneMapping.java:987)
      at
      oracle.toplink.essentials.mappings.ForeignReferenceMapping.valueFromRow(ForeignReferenceMapping.java:837)
      at
      oracle.toplink.essentials.mappings.ForeignReferenceMapping.buildCloneFromRow(ForeignReferenceMapping.java:1
      34)
      at
      oracle.toplink.essentials.internal.descriptors.ObjectBuilder.buildAttributesIntoWorkingCopyClone(ObjectBuil
      der.java:1070)
      at
      oracle.toplink.essentials.internal.descriptors.ObjectBuilder.buildWorkingCopyCloneFromRow(ObjectBuilder.jav
      a:1177)
      at
      oracle.toplink.essentials.internal.descriptors.ObjectBuilder.buildObjectInUnitOfWork(ObjectBuilder.java:401
      )
      at
      oracle.toplink.essentials.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:370)
      at
      oracle.toplink.essentials.queryframework.ReportQueryResult.buildResult(ReportQueryResult.java:118)
      at
      oracle.toplink.essentials.queryframework.ReportQueryResult.<init>(ReportQueryResult.java:71)
      at
      oracle.toplink.essentials.queryframework.ReportQuery.buildObject(ReportQuery.java:516)
      at
      oracle.toplink.essentials.queryframework.ReportQuery.buildObjects(ReportQuery.java:574)
      at
      oracle.toplink.essentials.queryframework.ReportQuery.executeDatabaseQuery(ReportQuery.java:699)
      at
      oracle.toplink.essentials.queryframework.DatabaseQuery.execute(DatabaseQuery.java:609)
      at
      oracle.toplink.essentials.queryframework.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:796)
      at
      oracle.toplink.essentials.queryframework.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java
      :850)
      at
      oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2223)
      at
      oracle.toplink.essentials.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:925)
      at
      oracle.toplink.essentials.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:897)
      at
      oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.executeReadQuery(EJBQueryImpl.java:345)
      at
      oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.getResultList(EJBQueryImpl.java:431)

        Activity

        Hide
        marina vatkina added a comment -

        Assigned

        Show
        marina vatkina added a comment - Assigned
        Hide
        mb124283 added a comment -

        Started looking into this.

        Michael

        Show
        mb124283 added a comment - Started looking into this. Michael
        Hide
        mb124283 added a comment -

        I changed the EJBQL compiler to make use of a new internal API on the
        ReportQuery query class allowing to pass fetch join expressions along with a
        variable that is selected. This makese sure that for a query
        SELECT c from Customer c JOIN FETCH c.spouse
        the generated SQL selects the related spouse instacne along with the customer.

        Show
        mb124283 added a comment - I changed the EJBQL compiler to make use of a new internal API on the ReportQuery query class allowing to pass fetch join expressions along with a variable that is selected. This makese sure that for a query SELECT c from Customer c JOIN FETCH c.spouse the generated SQL selects the related spouse instacne along with the customer.

          People

          • Assignee:
            mb124283
            Reporter:
            smcgowan
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: