You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by "Akins, Greg" <ga...@amervideo.com> on 2005/02/15 14:36:50 UTC

Reading from different datasources in same SqlMapClient instance

Maybe I didn't express myself well enough in my last post.

I have a SqlMap that has a select attribute on the result, so that the
Collection is read from another statement.

What I'd really like to be able to do, is use a Java class (instead of a
sql statement), so I can get the collection from another datasource.

Is there a way to force Ibatis to execute a Java method to populate a
result set, instead of just using the SqlMaps?

<resultMap id="getWareResult" class="ware" >
<result property="id" column="WareId" />
<result property="laserId" column="LaserId" />
<result property="mold" column="mold_id" select="getMoldById" />
<result property="avpId" column="AvpId" /> 
</resultMap>
<statement id="getWares" resultMap="getWareResult" >
select WareId, LaserId, MoldId, AvpId 
from Ware
where AvpId = #id#
</statement>

Greg Akins
Software Engineer
Sony Electronics, STP Systems
724.696.7322 (Sony)
724.696.6147 (AV)
724.454.7790 (Cell)
412.590.3973 (Pager)

Re: Reading from different datasources in same SqlMapClient instance

Posted by Brandon Goodin <br...@gmail.com>.
There is no way to accomplish this with the resultmap. You could
simply get your list with the select and then iterate over it and
populate the complex property (mold) by calling getMoldById statement.

Brandon


On Tue, 15 Feb 2005 08:36:50 -0500, Akins, Greg <ga...@amervideo.com> wrote:
> Maybe I didn't express myself well enough in my last post.
> 
> I have a SqlMap that has a select attribute on the result, so that the
> Collection is read from another statement.
> 
> What I'd really like to be able to do, is use a Java class (instead of a
> sql statement), so I can get the collection from another datasource.
> 
> Is there a way to force Ibatis to execute a Java method to populate a
> result set, instead of just using the SqlMaps?
> 
> <resultMap id="getWareResult" class="ware" >
> <result property="id" column="WareId" />
> <result property="laserId" column="LaserId" />
> <result property="mold" column="mold_id" select="getMoldById" />
> <result property="avpId" column="AvpId" />
> </resultMap>
> <statement id="getWares" resultMap="getWareResult" >
> select WareId, LaserId, MoldId, AvpId
> from Ware
> where AvpId = #id#
> </statement>
> 
> Greg Akins
> Software Engineer
> Sony Electronics, STP Systems
> 724.696.7322 (Sony)
> 724.696.6147 (AV)
> 724.454.7790 (Cell)
> 412.590.3973 (Pager)
>