You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by ram <ra...@yahoo.co.in> on 2016/02/24 22:43:04 UTC

@sqlresultsetmapping columns

Hi,        i have an entity called order which contains 10 columns and also has embeded id(composite key)  coulmns which contains 5 fields in entity order.

 i was trying to build sql resultsetmapping in orm.xml



 <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>
 <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 am getting the 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.



Re: @sqlresultsetmapping columns

Posted by Mark Struberg <st...@yahoo.de>.
How does your source code look like?
Maybe the problem is not in the orm.xml but in how you created your combined pk?

LieGrue,
strub


> Am 24.02.2016 um 22:43 schrieb ram <ra...@yahoo.co.in>:
> 
> Hi,        i have an entity called order which contains 10 columns and also has embeded id(composite key)  coulmns which contains 5 fields in entity order.
> 
>  i was trying to build sql resultsetmapping in orm.xml
> 
> 
> 
> <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>
> <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 am getting the 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.
> 
>