Uploaded image for project: 'OpenJPA'
  1. OpenJPA
  2. OPENJPA-2218

SQL-Result-set returns duplicate objects for the repetitive entity

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Critical
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: jpa
    • Labels:
      None
    • Environment:
      Open JPA 1.x, WAS 7.0, Windows 7 64 bit, Java 1.6

      Description

      I have a native query for a join operation and corresponding entity-resultset defined in the orm.xml as follows,

      <named-native-query name="getPaymentById" result-set-mapping="paymentMapping">
      <query>SELECT T1., T2. FROM TEMP.PAYMENT T1 LEFT JOIN TEMP.PAYMENT T12 ON T1.Col1 = T2.Col2 WHERE T1.PAYMENT_ID = ?
      </query>
      </named-native-query>

      <sql-result-set-mapping name="paymentMapping">
      <entity-result entity-class="Payment"></entity-result>
      <entity-result entity-class="Payment"></entity-result>
      </sql-result-set-mapping>

      Where the SQL result for one of the scenario in the above query is, T1 returns records for all the columns and T2 is null for all the columns.

      But the way entity mappings returned by the Query class's getResultList() method is T1 and T2 has same instances and same records. i.e., T2 doesnot returns Null value but instead uses the same value as T1.
      The java code which returns this result is as follows,

      Query createNamedQuery = getEntityManagerDao().getEntityManager().createNamedQuery("getPaymentById");
      createNamedQuery.setParameter(1,paymentID);
      List<Object[]> result = (List<Object[]>)createNamedQuery.getResultList();

      Please let me know if i am missing something or it is an JPA issue.
      THanks in advance.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              sat1985 Sathish
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: