ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ted Schrader" <tschra...@gmail.com>
Subject Re: using $value$ with collection property
Date Thu, 09 Mar 2006 15:36:42 GMT
Hello,

I neglected to state something important in my first message:  I'm
using version 2.1.5:

>From release.txt:
>> Build Date: 2005/07/17 20:58
>> Build Number: 582
>>
>> ------------------------------
>>  2.1.5 - July 17, 2005
>> ------------------------------

Thanks,

Ted

On 09/03/06, Ted Schrader <tschrader@gmail.com> wrote:
> Hello,
>
> I'm having some trouble populating a collection property on my result
> bean in an "iBATIS" way while using the $value$ idiom.  I have an
> object structure like this:
>
> OrderDetailVO (order header info value object)
>       OrderDetailVO.orderNum  (String)
>       OrderDetailVO.detailLines  (List of OrderDetailLineVO objects)
>
> I'm attempting to gradually move towards avoiding N+1, so my
> intermediate step is the config below.  In my queries, please note the
> use of "FROM $companyLibrary$.ORHED" and "FROM $companyLibrary$.ORDET"
> (data for our various clients are stored in different AS/400
> libraries.  For the non-AS/400 folks, think "database" when you see
> "library").  It appears the value for $companyLibrary$ is not getting
> passed along to the second query for order detail lines, per this
> error:
>
> com.ibatis.common.exception.NestedRuntimeException: Error lazy loading result.
> Cause: com.ibatis.common.jdbc.exception.NestedSQLException:
> --- The error occurred in mycom/sqlmaps/OrderDetail.xml.
> --- The error occurred while executing query.
> --- Check the SELECT ODITEM FROM .ORDET WHERE ODCOID = ? AND ODORD# =
> ? ORDER BY ODITEM.
> --- Check the SQL Statement (preparation failed).
> --- Cause: java.sql.SQLException: [SQL0104] Token . was not valid.
> Valid tokens: ( TABLE
>
> Without further ado, here's the distilled mapping:
>
> <sqlMap namespace="OrderDetail">
>         <resultMap id="orderDetailResult" class="mycom.OrderDetailVO">
>                 <result column="OHORD#" property="orderNum" />
>
>                 <!-- load list of detail lines. -->
>                 <result column="{companyId=OHCOID, orderNum=OHORD#}"
>                         property="detailLines"
>                         select="OrderDetail.orderDetailLines" />
>         </resultMap>
>
>         <select id="orderDetail" resultMap="orderDetailResult">
>                 SELECT OHCOID, OHORD##
>                   FROM $companyLibrary$.ORHED
>                  WHERE OHCOID = #companyId#
>                    AND OHORD## = #orderNum#
>         </select>
>
>
>         <resultMap id="orderDetailLineResult" class="mycom.OrderDetailLineVO">
>                 <result column="ODITEM" property="item" />
>         </resultMap>
>
>         <select id="orderDetailLines" resultMap="orderDetailLineResult">
>                 SELECT ODITEM
>                   FROM $companyLibrary$.ORDET
>                  WHERE ODCOID = #companyId#
>                    AND ODORD## = #orderNum#
>                  ORDER BY ODITEM
>         </select>
> </sqlMap>
>
> Any ideas?  Thanks,
>
> Ted
>

Mime
View raw message