You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Sathish (JIRA)" <ji...@apache.org> on 2012/06/19 15:54:43 UTC

[jira] [Created] (OPENJPA-2218) SQL-Result-set returns duplicate objects for the repetitive entity

Sathish created OPENJPA-2218:
--------------------------------

             Summary: SQL-Result-set returns duplicate objects for the repetitive entity
                 Key: OPENJPA-2218
                 URL: https://issues.apache.org/jira/browse/OPENJPA-2218
             Project: OpenJPA
          Issue Type: Bug
          Components: jpa
         Environment: Open JPA 1.x, WAS 7.0, Windows 7 64 bit, Java 1.6
            Reporter: Sathish
            Priority: Critical


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.


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira