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 Fri, 10 Mar 2006 14:00:56 GMT
Hi Larry,

Your observation is an excellent one, assuming I only needed to access
a single library(database).  In addition, I could also specify a
default library on the DataSource config hosted by WebSphere, which I
do use for every other web application I maintain (which is great
because my SQL doesn't have to know about libraries at all, just
files[tables]).

In this case, however, the application must span different libraries
on the fly. In other words, as an administrator of the site, I have a
choice of which companies to see. I can pick companyX which means I
need libraryX.  When I change to companyY, the application should then
look at libraryY.  This is why I'm using the $companyLibrary$ idiom in
the SQL. The schemas are identical between the various libraries, so I
can get away with doing this.

I've got it working good enough, fast enough, and clean enough.  At
this point, I'm simply curious if the non-propagation of $value$ to
complex property queries is a bug, or perhaps something that was
addressed sometime between versions 2.1.5 and 2.1.7.

Thanks again!

Ted

On 10/03/06, Larry Meadors <lmeadors@apache.org> wrote:
> Ted, I think if you use system naming on the 400, you can specify a
> library list in the connection string...if that helps.
>
> Larry
>
>
> On 3/9/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