I have an entity called order which contains 10 columns and also has embedded id(composite key) columns which contains 5 fields in entity order.
Here is my sql query
<named-native-query name="OrderQuery" result-set-mapping="OrderQueryResultSetMapping">
<query>
<![CDATA[SELECT t0.colum2, t0.column4, to.embededid.colum3, e mbededid.colum1, FROM order t0 WHERE t0.orderid = ?1 ]]>
</query>
</named-native-query>
I was trying to build sql resultsetmapping in orm.xml
<sql-result-set-mapping name="OrderQueryResultSetMapping">
<entity-result entity-class="order">
<field-result name="column2" column="column_2" />
<field-result name="column4" column="column_4" />
</entity-result>
<entity-result entity-class="orderembededId">
<field-result name="column3" column="column_3" />
<field-result name="column4"1column="column_1" />
</entity-result>
</sql-result-set-mapping>
I don't have issues in query execution, but getting error in sqlResultSetMapping
. I'm getting following error.
Exception in thread "main" <openjpa-2.4.0-r422266:1674604 fatal general error>
org.apache.openjpa.persistence.PersistenceException: [jcc][t4][10145][10897]
[3.58.81] Invalid parameter 0: Parameter index is out of range. ERRORCODE=-4461, SQLSTATE=42815
Can we do this kind of mapping? If so, how do client knows what are the columns are populated for Order entity as part of this query?