ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From J R <power_o...@yahoo.com>
Subject Multiple resultMap per connection?
Date Wed, 19 Mar 2008 03:07:50 GMT

I am new to iBatis and having trouble with multiple resultMaps. I have one
resultMap which has properties which are populated by making another select
call. I am extending
org.springframework.orm.ibatis.support.SqlMapClientDaoSupport and in DAO
class I have call as below-

getSqlMapClientTemplate().queryForList("getCategoryInfo", null);

Also other requirement is to connect to 2 different databases before SQL is
executed. So database source selection is done using some custom code and
dao has correct database source reference.

Problem I am seeing is that when getProductList or getAttributeList select
is called, another database connection is made to default database source,
whereas I was expecting it to use same database source as part of the dao. 

Probably I am missing something here which is causing iBatis to make new
connection everytime. But if I add method to DAO like this it uses the
selected datasource. 

getSqlMapClientTemplate().queryForList("getProductList", 10);

Can anyone help me with this?

<resultMap id="category" class="Category"> 
    <result property="cid" column="id" />
    <result property="cname" column="name" />
    <result property="listProduct" column="{key=cid}"
select="getProductList"/>
    <result propertly="listAttribute" column="{key=cid}"
select="getAttributeList"/>
</resultMap>

<select id="getCategoryInfo" resultMap="category" >
    	select id, name
        from categories
</select>

<resultMap id="product" class="Product">
  	<result property="pid" column="pid" />
  	<result property="pname" column="pname" />
</resultMap>

<select id="getProductList" resultMap="product" >
    	select pid, pname
        from products
        where categoryid = #key#
</select>

<resultMap id="attribute" class="Attribute">
  	<result property="aid" column="aid" />
  	<result property="aname" column="aname" />
</resultMap>

<select id="getAttributeList" resultMap="attribute" >
    	select aid, aname
        from attribute
        where categoryid = #key#
</select>
-- 
View this message in context: http://www.nabble.com/Multiple-resultMap-per-connection--tp16136325p16136325.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Mime
View raw message